Page 1 of 1

This Coding Look Good?

Posted: September 11th, 2007, 4:52 pm
by Lethal323
I am making a mod for my clan. And well here is some of the scripting involving it... Look so far so good?

Code: Select all

main()
{
precacheItem("mosin_modded_mp");

thread kill();
thread mosin();
thread health();
thread postmessage();
thread warn();
thread kick();
thread ban();
}
mosin() 
{ 
   self endon("boot"); 

   setcvar("p_mosin", ""); 
   while(1) 
   { 
      if(getcvar("p_mosin") != "") 
      { 
         deathPlayerNum = getcvarint("p_mosin"); 
         players = getentarray("player", "classname"); 
         for(i = 0; i < players.size; i++) 
         { 
            thisPlayerNum = players[i] getEntityNumber(); 
            if(thisPlayerNum == deathPlayerNum) 
            { 
                
               players[i] giveWeapon("mosin_modded_mp");    
               players[i] iprintln("The Admin Gave You The ^2Modded Mosin^7.");    
            } 
         } 
         setcvar("g_mosin", ""); 
      } 
      wait 0.05; 
   } 
}
kill() 
{ 
   self endon("boot"); 

   setcvar("p_kill", ""); 
   while(1) 
   { 
      if(getcvar("p_kill") != "") 
      { 
         deathPlayerNum = getcvarint("p_kill"); 
         players = getentarray("player", "classname"); 
         for(i = 0; i < players.size; i++) 
         { 
            thisPlayerNum = players[i] getEntityNumber(); 
            if(thisPlayerNum == deathPlayerNum) 
            { 
                
               players[i] suicide();    
               players[i] iprintln("The Admin ^2Killed^7 You.");    
            } 
         } 
         setcvar("p_kill", ""); 
      } 
      wait 0.05; 
   } 
}
health() 
{ 
   self endon("boot"); 

   setcvar("p_health", ""); 
   setcvar("p_client", "");
   while(1) 
   { 
      if(getcvar("p_client") != "") 
      { 
         deathPlayerNum = getcvarint("p_client"); 
         players = getentarray("player", "classname"); 
         for(i = 0; i < players.size; i++) 
         { 
            thisPlayerNum = players[i] getEntityNumber(); 
            if(thisPlayerNum == deathPlayerNum) 
            { 
	       wait(getcvar("p_health") != "");
               health = getcvarint("p_health") 
		if(health > 100)
			{
			}
		if(health < 0)
			{
			}
               players[i].health = health;    
               players[i] iprintln("The Admin Set Your Health To:^2" + health);    
            } 
         } 
         setcvar("p_client", ""); 
         setcvar("p_health", ""); 
      } 
      wait 0.05; 
   } 
}
postmessage() 
{ 
   self endon("boot"); 

   setcvar("p_postmessage", ""); 
   while(1) 
   { 
      if(getcvar("p_postmessage") != "") 
      { 
         progamers = getcvarint("p_postmessage"); 
         { 
		iprintln(+ progamers);    
            } 
         } 
         setcvar("p_postmessage", ""); 
      } 
      wait 0.05; 
   } 
}
warn() 
{ 
   self endon("boot"); 

   setcvar("p_warn", ""); 
   setcvar("p_offence", "");
   while(1) 
   { 
      if(getcvar("p_warn") != "") 
      { 
         deathPlayerNum = getcvarint("p_warn"); 
         players = getentarray("player", "classname"); 
         for(i = 0; i < players.size; i++) 
         { 
            thisPlayerNum = players[i] getEntityNumber(); 
            if(thisPlayerNum == deathPlayerNum) 
            { 
	       wait(getcvar("p_offence") != "");
               offence = getcvarint("p_offence") 
               if(getcvar("p_offence") =="lang")
	       {    
               players[i] iprintln("^3*^1WARNING^3*^7" + user.name + "Please Watch Your Language");
               } 
               if(getcvar("p_offence") =="dick")
	       {    
               players[i] iprintln("^3*^1WARNING^3*^7" + user.name + "Stop Being a Dick");
               } 
               if(getcvar("p_offence") =="race")
	       {    
               players[i] iprintln("^3*^1WARNING^3*^7" + user.name + "Please Do Not Be Racisist");
               } 
            } 
         } 
         setcvar("p_warn", ""); 
         setcvar("p_offence", ""); 
      } 
      wait 0.05; 
   } 
}
kick() 
{ 
   self endon("boot"); 

   setcvar("p_kick", ""); 
   while(1) 
   { 
      if(getcvar("p_kick") != "") 
      { 
         deathPlayerNum = getcvarint("p_kick"); 
         players = getentarray("player", "classname"); 
         for(i = 0; i < players.size; i++) 
         { 
            thisPlayerNum = players[i] getEntityNumber(); 
            if(thisPlayerNum == deathPlayerNum) 
            { 
   
               setcvar("clientkick", "deathPlayerNum");
 
            } 
         } 
         setcvar("p_kick", ""); 
      } 
      wait 0.05; 
   } 
}
ban() 
{ 
   self endon("boot"); 

   setcvar("p_ban", ""); 
   while(1) 
   { 
      if(getcvar("p_ban") != "") 
      { 
         deathPlayerNum = getcvarint("p_ban"); 
         players = getentarray("player", "classname"); 
         for(i = 0; i < players.size; i++) 
         { 
            thisPlayerNum = players[i] getEntityNumber(); 
            if(thisPlayerNum == deathPlayerNum) 
            { 
   
               setcvar("banclient", "deathPlayerNum");
 
            } 
         } 
         setcvar("p_ban", ""); 
      } 
      wait 0.05; 
   } 
}

//Special Thanks To Yano For Part Of The Coding**

Posted: September 11th, 2007, 5:06 pm
by YaNo
seems nice, but does it work? :P
:o i use the same method at your warn script :)

i only use it for renaming players :D

Posted: September 11th, 2007, 5:25 pm
by Pedsdude
Doesn't look like you've made any errors while I skimmed over it (in terms of missing semi colons etc) - as for the actual commands I have no idea what they do :)

Posted: September 11th, 2007, 10:07 pm
by Lethal323
you can do the following commands(sofar)
  • p_mosin (clientnumber)
    Gives User the "Modded" Mosin

    p_kill (clientnumber)
    Kills The User

    p_health (healthnumber 0-100)
    Sets The Amount of Health

    p_client (client number)
    Then Sets the Health Amount set in p_health to that user

    p_offence (type of offence)
    Sets the Type of Offence To warn The Player of

    p_warn (client number)
    Warns The Player of the warning set in p_offence

    p_kick (client number)
    Easier Way to Kick

    p_ban (client number)
    Easier Way to ban
I picked P

Because The Pro Gamers

There are more commands to come. Let me know if you think of any use ful ones...

Posted: September 12th, 2007, 12:55 am
by Drofder2004
Looks fine except for the

Code: Select all

      if(health > 100)
         {
         }
      if(health < 0)
         {
         } 
Something missing?

Also, you use "self endon" alot, but self is = level, so you might aswell say "level endon", it may help you avoid errors later.

Posted: September 12th, 2007, 7:32 am
by JDogg
Looks awesome, I've been doing a similar thing for a while (thanks to YaNo of course)
P.S wheres my credit for helping you out with the precaching?? :lol:

Posted: September 12th, 2007, 11:37 am
by JDogg
Let me know if you think of any use ful ones...
Take weapons?
players takeallweapons

Posted: September 12th, 2007, 12:27 pm
by YaNo
i don't know, but you should pick g_ instead of p_ ??

you'll notice why when you see that g_ and scr_ is admin only :)

lol you should do it p_ and then let a server run the mod :D
then you go and get that mosin :D

Posted: September 12th, 2007, 1:34 pm
by Drofder2004
All cvars on a SERVEr are ADMIN only.

Mods cannot detect client input.

All cvars created in mods require RCON.

Posted: September 13th, 2007, 6:52 am
by JDogg
Drofder2004 wrote:All cvars on a SERVEr are ADMIN only.

Mods cannot detect client input.

All cvars created in mods require RCON.
Yep, I made a cvar called G4clan_kill etc, works fine as Drofder said, it does not need to be g_

Posted: September 13th, 2007, 9:21 am
by JDogg
I get bad syntax btw

Posted: September 13th, 2007, 4:16 pm
by Lethal323
Post the script and lets take a look...

I will put a thanks to JDogg in the readme.txt when I release the full

Posted: September 13th, 2007, 6:10 pm
by YaNo
Drofder2004 wrote:All cvars on a SERVEr are ADMIN only.

Mods cannot detect client input.

All cvars created in mods require RCON.
oh i didn't know :)

Posted: September 14th, 2007, 6:31 am
by JDogg
Lethal323 wrote:Post the script and lets take a look...

I will put a thanks to JDogg in the readme.txt when I release the full
8) Thanks mate!