Tutorial: Player Controls

Tutorials for Call of Duty mapping

Moderator: Core Staff

Lethal323

Tutorial: Player Controls

Post by Lethal323 » July 25th, 2007, 11:41 am

ok well since I am at my moms and I dont have my video recording software so I cant do any of my modding ones. I decided to do a quick one on Player Controls


Taking and Giving Weapons:

Taking and Giving Weapons is very simple.

The code below with give the player a Kar98k

Code: Select all

main() 
{ 
maps\mp\_load::main(); 
thread give();
}
give()
}
self giveweapon("kar98k_mp"); 
}
--THE _MP IS VERY IMPORTANT--

Setting Ammo Amount:

This one is simple to:

Code: Select all

main() 
{ 
maps\mp\_load::main(); 
thread set();
}
set()    
{
self setweaponslotammo("primary", 0); 
self setweaponslotclipammo("primary", 0); 
}

In more detail:

Code: Select all

self setweaponslotammo("primary", 0); 
Sets the amount of ammo you have total.

Code: Select all

self setweaponslotclipammo("primary", 0);
Sets the amount of ammo you have in your clip.


Switching a player to a weapon:

Another Simple one:

Code: Select all

main() 
{ 
maps\mp\_load::main(); 
thread switch();
}
switch()    
{
self switchtoweapon("kar98k_mp"); 
}

Make sure you give the player the gun before you switch them to it!

or you can do

Code: Select all

main() 
{ 
maps\mp\_load::main(); 
thread switch();
}
switch()    
{
self switchtoweaponslot("primary"); 
}

Taking away all weapons:

Extremly Simple One:

This will remove all the players weapons:

Code: Select all

main() 
{ 
maps\mp\_load::main(); 
thread remove();
}
remove()    
{
self takeallweapons();
}

There are many many many, more player controls you can do! I will be adding to this tutorial as I get the motivation (LOL)

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

Post by YaNo » July 26th, 2007, 11:05 pm

i use the take all for the mass teleport in my fightmaps :P so they can't shoot ^^

Riley03
CJ Wannabe
CJ Wannabe
Posts: 5
Joined: July 13th, 2009, 11:28 pm

Re: Tutorial: Player Controls

Post by Riley03 » August 11th, 2009, 4:37 pm

you can also do

Code: Select all

main() 
{ 
maps\mp\_load::main(); 
thread setMaxAmmo();
}
setMaxAmmo()    
{
self giveMaxAmmo("kar98k_mp");}[code]

for max ammo but you need to have that weapon already

Riley03
CJ Wannabe
CJ Wannabe
Posts: 5
Joined: July 13th, 2009, 11:28 pm

Re: Tutorial: Player Controls

Post by Riley03 » August 11th, 2009, 4:38 pm

srry for double posting but cant edit my own posts? o.O

Code: Select all

main() 
{ 
maps\mp\_load::main(); 
thread setMaxAmmo();
}

setMaxAmmo() 
{
self giveMaxAmmo("kar98k_mp");
}

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

Re: Tutorial: Player Controls

Post by Drofder2004 » August 11th, 2009, 5:00 pm

Erm, one major flaw...

you are threading the function from a LEVEL thread, so:

level = self

These are player functions and cannot be cast on non-entities and self must be a player.
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

SubGunner
CJ Wannabe
CJ Wannabe
Posts: 17
Joined: February 16th, 2011, 10:41 pm

Re: Tutorial: Player Controls

Post by SubGunner » April 6th, 2011, 5:09 pm

Sorry to open this thread back up but can someone give me some code that actually works for setting the ammo count to 0?
For a bash only map?

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Tutorial: Player Controls

Post by IzNoGoD » April 6th, 2011, 6:41 pm

Code: Select all

main()
{
	//dunno what else goes here?
	thread waitforconnect();
}

waitforconnect()
{
	for(;;)
	{
		level waittill("connecting",player);
		player thread waitforspawn();
	}
}

waitforspawn()
{
	self endon("disconnect");
	for(;;)
	{
		self waittill("spawned_player");
		self setweaponslotammo("primary",0);
		self setweaponslotclipammo("primary",0);
		self setweaponslotammo("primaryb",0);
		self setweaponslotclipammo("primaryb",0);
		//maybe take the nades too?
	}
}
epic fail on level/self btw, i wrote a tut about it, maybe you should read it?
LMGTFY!

Its not a glitch... Its the future!

SubGunner
CJ Wannabe
CJ Wannabe
Posts: 17
Joined: February 16th, 2011, 10:41 pm

Re: Tutorial: Player Controls

Post by SubGunner » April 6th, 2011, 7:13 pm

still not workin...thanks for the attempt tho dude!

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Tutorial: Player Controls

Post by IzNoGoD » April 6th, 2011, 8:54 pm

What cod is this? cause i dont know the exact notifys in all but cod2 1.3
LMGTFY!

Its not a glitch... Its the future!

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

Re: Tutorial: Player Controls

Post by Pedsdude » April 6th, 2011, 10:06 pm

CoD, not CoD2.
Image
Image

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

Re: Tutorial: Player Controls

Post by Drofder2004 » April 6th, 2011, 10:35 pm

epic fail on level/self btw, i wrote a tut about it, maybe you should read it?
The guy who made the scripting error made the post in 2009, I don't think he will be reading this topic :P
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

SubGunner
CJ Wannabe
CJ Wannabe
Posts: 17
Joined: February 16th, 2011, 10:41 pm

Re: Tutorial: Player Controls

Post by SubGunner » April 6th, 2011, 11:22 pm

Yep COD1...no wonder it wouldnt work..lol
But the map played ok so thats good :lol:

SubGunner
CJ Wannabe
CJ Wannabe
Posts: 17
Joined: February 16th, 2011, 10:41 pm

Re: Tutorial: Player Controls

Post by SubGunner » April 9th, 2011, 11:28 am

So this wont work for a CoD1 map or just nobody knows how to do it?

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Tutorial: Player Controls

Post by IzNoGoD » April 9th, 2011, 12:05 pm

I just dont have the right notifys, otherwise it would work.
LMGTFY!

Its not a glitch... Its the future!

IzNoGoD
CJ Worshipper
CJ Worshipper
Posts: 343
Joined: January 6th, 2009, 8:39 pm
Location: Netherlands/Holland

Re: Tutorial: Player Controls

Post by IzNoGoD » April 9th, 2011, 12:30 pm

where the hell is the edit button?

Try it with waittill("spawned"); instead of waittill("spawned_player");, so remove the _player from the waittill.
LMGTFY!

Its not a glitch... Its the future!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests