Knife Only Map

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

Moderator: Core Staff

Post Reply
J.Octavian
CJ Wannabe
CJ Wannabe
Posts: 4
Joined: August 29th, 2012, 6:34 am

Knife Only Map

Post by J.Octavian » August 29th, 2012, 6:38 am

Hi, I attempted to read the scripting tutorial posted here, because I'm attempting to keep players from shooting in a custom Knife Only map, and I cannot wrap my head around any of it. I was wondering if someone could simply tell me how to disable all weapons just in one map, so all they'd have to use is the knife. Any help would be appreciated.

User avatar
Goro92
CJ Spammer!
CJ Spammer!
Posts: 605
Joined: March 7th, 2011, 5:54 pm
Location: Brescia, Italy

Re: Knife Only Map

Post by Goro92 » August 29th, 2012, 11:13 am

try TakeAllWeapons() or DisableWeapons()


check this website: http://www.zeroy.com/script/
Image

J.Octavian
CJ Wannabe
CJ Wannabe
Posts: 4
Joined: August 29th, 2012, 6:34 am

Re: Knife Only Map

Post by J.Octavian » August 29th, 2012, 11:58 am

I know nothing about scripting, and all I got from that site was

level.player TakeAllWeapons();

I have no idea what to do with it. Putting it into my mp_mymap.gsc gave me a script runtime error saying undefined is not an entity.

User avatar
Rezil
Core Staff
Core Staff
Posts: 2030
Joined: July 24th, 2006, 11:21 am
Location: Cramped in a small cubicle/making another jump map

Re: Knife Only Map

Post by Rezil » August 29th, 2012, 12:06 pm

You have to get all the players, either by waiting until a player connects or getting the array of player entities(getEntArray("player", "classname")). Only then can you call takeAllWeapons() on the player.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.

J.Octavian
CJ Wannabe
CJ Wannabe
Posts: 4
Joined: August 29th, 2012, 6:34 am

Re: Knife Only Map

Post by J.Octavian » August 29th, 2012, 12:10 pm

Ok so how would I take all weapons from the players as they spawn into my map?

F |Madness| U
CJ G0D!
CJ G0D!
Posts: 1575
Joined: June 3rd, 2009, 9:02 pm
Location: Cardiff University, UK

Re: Knife Only Map

Post by F |Madness| U » August 29th, 2012, 4:20 pm

Code: Select all

onPlayerSpawned() //everything in this function happens to each player when they spawn
{
        self waittill("spawned_player");        
        self TakeAllWeapons(); //should remove all weapons
        self giveWeapon ( "knife_mp" );
        self giveWeapon( "usp_mp" ); // gives them a usp and a knife
        self setWeaponAmmoClip("usp_mp", 0);
        self setWeaponAmmoStock("usp_mp", 0); // removes ammo from the usp so they cannot fire
        self switchtoweapon("usp_mp"); //switches to the usp, let the fun begin (hopefully)
}
These functions work for Black Ops, I am assuming they are all present in CoD4 also. I only gave them the usp because 1) I'm not sure if you can knife if you arn't holding a weapon and 2) many players simply like holding a gun whilst knifing.
-

J.Octavian
CJ Wannabe
CJ Wannabe
Posts: 4
Joined: August 29th, 2012, 6:34 am

Re: Knife Only Map

Post by J.Octavian » August 30th, 2012, 2:37 am

This doesn't work. I keep getting "script compile error bad syntax { "

Post Reply

Who is online

Users browsing this forum: No registered users and 36 guests