This Coding Look Good?

Have questions about CoD/UO mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
Lethal323

This Coding Look Good?

Post by Lethal323 » September 11th, 2007, 4:52 pm

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**

User avatar
YaNo
CJ Worshipper
CJ Worshipper
Posts: 460
Joined: May 5th, 2005, 9:34 pm
Location: Azeroth
Contact:

Post by YaNo » September 11th, 2007, 5:06 pm

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

Pedsdude
Site Admin
Site Admin
Posts: 15909
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » September 11th, 2007, 5:25 pm

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 :)
Image
Image

Lethal323

Post by Lethal323 » September 11th, 2007, 10:07 pm

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...

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 12th, 2007, 12:55 am

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.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

JDogg
Too cool for CoDJumper
Too cool for CoDJumper
Posts: 3617
Joined: August 28th, 2007, 11:46 am
Location: Melbourne, Australia

Post by JDogg » September 12th, 2007, 7:32 am

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:
Image
Image

JDogg
Too cool for CoDJumper
Too cool for CoDJumper
Posts: 3617
Joined: August 28th, 2007, 11:46 am
Location: Melbourne, Australia

Post by JDogg » September 12th, 2007, 11:37 am

Let me know if you think of any use ful ones...
Take weapons?
players takeallweapons
Image
Image

User avatar
YaNo
CJ Worshipper
CJ Worshipper
Posts: 460
Joined: May 5th, 2005, 9:34 pm
Location: Azeroth
Contact:

Post by YaNo » September 12th, 2007, 12:27 pm

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

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 12th, 2007, 1:34 pm

All cvars on a SERVEr are ADMIN only.

Mods cannot detect client input.

All cvars created in mods require RCON.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

JDogg
Too cool for CoDJumper
Too cool for CoDJumper
Posts: 3617
Joined: August 28th, 2007, 11:46 am
Location: Melbourne, Australia

Post by JDogg » September 13th, 2007, 6:52 am

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_
Image
Image

JDogg
Too cool for CoDJumper
Too cool for CoDJumper
Posts: 3617
Joined: August 28th, 2007, 11:46 am
Location: Melbourne, Australia

Post by JDogg » September 13th, 2007, 9:21 am

I get bad syntax btw
Image
Image

Lethal323

Post by Lethal323 » September 13th, 2007, 4:16 pm

Post the script and lets take a look...

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

User avatar
YaNo
CJ Worshipper
CJ Worshipper
Posts: 460
Joined: May 5th, 2005, 9:34 pm
Location: Azeroth
Contact:

Post by YaNo » September 13th, 2007, 6:10 pm

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 :)

JDogg
Too cool for CoDJumper
Too cool for CoDJumper
Posts: 3617
Joined: August 28th, 2007, 11:46 am
Location: Melbourne, Australia

Post by JDogg » September 14th, 2007, 6:31 am

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!
Image
Image

Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests