Author |
Topic: Weapons to specified ppl (GUID) |
LiQ.HeaDShOt |
|
General Member Since: Jun 1, 2010 Posts: 51 Last: Feb 21, 2011 [view latest posts] |
|
|
Category: CoD4 Scripting Posted: Wednesday, Aug. 4, 2010 02:20 pm |
|
Xylozi writes...Quote: To add a second weapon would require a little re-scripting, so if you just listed all the weapons you want given, I can add it to the script.
hmm..
well its:
rpd_mp
m14_mp
m4_mp
and later i would like to add some other weapons..
if it is a little complex, plz rescript it and comment the script so I can guide myself through the comments xD
Thanks again :D
|
|
|
|
LiQ.HeaDShOt |
|
General Member Since: Jun 1, 2010 Posts: 51 Last: Feb 21, 2011 [view latest posts] |
|
|
|
LiQ.HeaDShOt |
|
General Member Since: Jun 1, 2010 Posts: 51 Last: Feb 21, 2011 [view latest posts] |
|
|
Category: CoD4 Scripting Posted: Wednesday, Aug. 11, 2010 07:53 pm |
|
Hey every1 again.
Since nobody helped me with the rescripting, i tried to rescript it myself!
I changed the comments for what i want the script to do (at least the idea is there ) and added/deleted some unwanted lines.
Code:
setupWeapons()
{
// For each seperate guid, add a space between them
level.allowedGUIDS = "guidONE guidTWO";
// Change "ak47_mp" to the weapon of your choice
level.specialWeapon = "ak47_mp";
level.specialWeapon2 = "m21_mp";
level thread monitorDvar();
level thread onPlayerConnect();
}
onPlayerConnect()
{
for(;;)
{
level waittill( "connected", player );
player thread OnSpawn();
}
}
OnSpawn()
{
self endon( "disconnect" );
for(;;)
{
self waittill( "spawned" );
self thread checkGUID();
}
}
checkGUID()
{
self.isSpecial = false;
allowedGUIDs = strTok( level.allowedGUIDS, " " );
for( i = 0; i < allowedGUIDs.size; i++ )
{
guid = allowedGUIDs[i];
if( ToLower( self GetGUID() ) == ToLower( guid ) )
self.isSpecial = true;
}
if( self.isSpecial )
{
// Should be added to the inventory (more slots?)
self GiveWeapon( level.specialWeapon );
self GiveMaxAmmo( level.specialWeapon );
self GiveWeapon( level.specialWeapon2 );
self GiveMaxAmmo( level.specialWeapon2 );
}
}
monitorDvar()
{
setDvar( "scr_giveWeapon", "" );
while(1)
{
if( getDvar( "scr_giveWeapon" ) != "" )
thread giveWeapon();
wait 0.05;
}
}
giveWeapon()
{
// When typing in the command, do /rcon scr_giveWeapon PLAYERID WEAPONNAME
string = strTok( getDvar( "scr_giveWeapon" ), " " );
setDvar( "scr_giveWeapon", "" );
if( !isDefined( string[0] ) ||!isDefined( string[1] ) )
return;
players = getEntArray( "player", "classname" );
for( i = 0; i < players.size; i++ )
{
player = players[i];
if( player getEntityNumber() == int( string[0] ) )
{
player giveWeapon( string[1] );
player giveMaxAmmo( string[1] );
}
}
}
If there are any errors, correct them plz.
Thank you
|
|
|
|
LiQ.HeaDShOt |
|
General Member Since: Jun 1, 2010 Posts: 51 Last: Feb 21, 2011 [view latest posts] |
|
|
Category: CoD4 Scripting Posted: Friday, Aug. 13, 2010 01:02 am |
|
help?
need some1 to check if the script is correct..
Maybe the level.specialWeapon2 isnt needed because im specifying the weapon name.
Plz help me..
As I said, idk scripting but im trying to do my best since nobody wants to help me...
Thanks,
LiQ.HeaDShOt. |
|
|
|
Xylozi |
General Member Since: Jul 12, 2008 Posts: 218 Last: Mar 1, 2012 [view latest posts] |
|
|
|
|
LiQ.HeaDShOt |
|
General Member Since: Jun 1, 2010 Posts: 51 Last: Feb 21, 2011 [view latest posts] |
|
|
Category: CoD4 Scripting Posted: Friday, Aug. 13, 2010 10:20 pm |
|
Xylozi writes...Quote: This works with arrays, which means you can easily add more guids/weapons.
Code:
setupWeapons()
{
// To add a new weapon/guid:
// Copy the last level.sWeapon[level.sWeapons.size] line and change the filename in the " "
level.allowedGUIDs = []
level.allowedGUIDs[level.allowedGUIDs.size] = "GUIDONE";
level.allowedGUIDs[level.allowedGUIDs.size] = "GUIDTWO";
level.sWeapon = []
level.sWeapon[level.sWeapon.size] = "rpd_mp";
level.sWeapon[level.sWeapon.size] = "m14_mp";
level.sWeapon[level.sWeapon.size] = "m4_mp";
level thread monitorDvar();
level thread onPlayerConnect();
}
onPlayerConnect()
{
for(;;)
{
level waittill( "connected", player );
player thread OnSpawn();
}
}
OnSpawn()
{
self endon( "disconnect" );
for(;;)
{
self waittill( "spawned" );
self thread checkGUID();
}
}
checkGUID()
{
self.isSpecial = false;
for( i = 0; i < level.allowedGUIDs.size; i++ )
{
guid = level.allowedGUIDs[i];
if( ToLower( self GetGUID() ) == ToLower( guid ) )
self.isSpecial = true;
}
if( self.isSpecial )
{
for( w = 0; w < level.sWeapon.size; w++ )
{
self giveWeapon( level.sWeapon[w] );
self giveMaxAmmo( level.sWeapon[w] );
}
}
}
monitorDvar()
{
setDvar( "scr_giveWeapon", "" );
while(1)
{
if( getDvar( "scr_giveWeapon" ) != "" )
thread giveWeapon();
wait 0.05;
}
}
giveWeapon()
{
// When typing in the command, do /rcon scr_giveWeapon PLAYERID WEAPONNAME
string = strTok( getDvar( "scr_giveWeapon" ), " " );
setDvar( "scr_giveWeapon", "" );
if( !isDefined( string[0] ) ||!isDefined( string[1] ) )
return;
players = getEntArray( "player", "classname" );
for( i = 0; i < players.size; i++ )
{
player = players[i];
if( player getEntityNumber() == int( string[0] ) )
{
player giveWeapon( string[1] );
player giveMaxAmmo( string[1] );
}
}
}
Thx for the script m8.
Great work :D |
|
|
|
LiQ.HeaDShOt |
|
General Member Since: Jun 1, 2010 Posts: 51 Last: Feb 21, 2011 [view latest posts] |
|
|
|
LiQ.HeaDShOt |
|
General Member Since: Jun 1, 2010 Posts: 51 Last: Feb 21, 2011 [view latest posts] |
|
|
Category: CoD4 Scripting Posted: Wednesday, Aug. 18, 2010 11:22 pm |
|
Hello anyone?
Rly need help..
Need some1 to tell me how to install the script.
I know like:
Code:
maps
mp
gametypes
But should I give the script some special name??
Do I have to add a line to _globallogic?
Thanks for the help.
|
|
|
|
LiQ.HeaDShOt |
|
General Member Since: Jun 1, 2010 Posts: 51 Last: Feb 21, 2011 [view latest posts] |
|
|
|
Xylozi |
General Member Since: Jul 12, 2008 Posts: 218 Last: Mar 1, 2012 [view latest posts] |
|
|
|
Category: CoD4 Scripting Posted: Saturday, Aug. 21, 2010 07:57 pm |
|
To include a .GSC file in a pre-built mod, you will need to create a server-side IWD. To do so:
1. Download these tools (FF Decompiler): http://modsonline.com/Downloads-full-4786.html
2. Decompile the mod, and find the _globallogic.gsc
3. Find this section of the code:
Code: if ( !isDefined( level.tweakablesInitialized ) )
maps\mp\gametypes\_tweakables::init();
Below it, add this:
Code: level thread setupWeapons();
4. Now, go to the bottom of the _globallogic.gsc and copy and paste this in:
Code:
setupWeapons()
{
// To add a new weapon/guid:
// Copy the last level.sWeapon[level.sWeapons.size] line and change the filename in the " "
level.allowedGUIDs = []
level.allowedGUIDs[level.allowedGUIDs.size] = "GUIDONE";
level.allowedGUIDs[level.allowedGUIDs.size] = "GUIDTWO";
level.sWeapon = []
level.sWeapon[level.sWeapon.size] = "rpd_mp";
level.sWeapon[level.sWeapon.size] = "m14_mp";
level.sWeapon[level.sWeapon.size] = "m4_mp";
level thread monitorDvar();
level thread onPlayerConnect();
}
onPlayerConnect()
{
for(;;)
{
level waittill( "connected", player );
player thread OnSpawn();
}
}
OnSpawn()
{
self endon( "disconnect" );
for(;;)
{
self waittill( "spawned" );
self thread checkGUID();
}
}
checkGUID()
{
self.isSpecial = false;
for( i = 0; i < level.allowedGUIDs.size; i++ )
{
guid = level.allowedGUIDs[i];
if( ToLower( self GetGUID() ) == ToLower( guid ) )
self.isSpecial = true;
}
if( self.isSpecial )
{
for( w = 0; w < level.sWeapon.size; w++ )
{
self giveWeapon( level.sWeapon[w] );
self giveMaxAmmo( level.sWeapon[w] );
}
}
}
monitorDvar()
{
setDvar( "scr_giveWeapon", "" );
while(1)
{
if( getDvar( "scr_giveWeapon" ) != "" )
thread giveWeapon();
wait 0.05;
}
}
giveWeapon()
{
// When typing in the command, do /rcon scr_giveWeapon PLAYERID WEAPONNAME
string = strTok( getDvar( "scr_giveWeapon" ), " " );
setDvar( "scr_giveWeapon", "" );
if( !isDefined( string[0] ) ||!isDefined( string[1] ) )
return;
players = getEntArray( "player", "classname" );
for( i = 0; i < players.size; i++ )
{
player = players[i];
if( player getEntityNumber() == int( string[0] ) )
{
player giveWeapon( string[1] );
player giveMaxAmmo( string[1] );
}
}
}
5. Save the _globallogic.gsc.
6. Go to your mod folder (the one you wish to edit) and make these folders, in one another:
Code: maps -> mp -> gametypes
6. Go in the gametypes folder, and copy and paste your _globallogic.gsc in.
To create the IWD, you need to do:
1. Install a compression program, e.g. 7zip
2. Right click on the maps folder and click Add to Archive
3. Click the .zip radio button
4. Name the file: z_svr_weapons.iwd and click Ok.
You now have your script 'installed' in a server-side IWD, which must be uploaded to your server (but NOT your redirect), in the mod folder your using. |
|
|
|