Author Topic: Help on ctf script  (Read 2482 times)

Tommy_Kills

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Help on ctf script
« on: August 16, 2011, 03:45:01 am »
Im trying to make a ctf script but idk how to make one icon do some while the other one does something esle
heres the code btw im new at scripting squirrel

Code: [Select]
function onPlayerConnect(player)
{
local REDFLAG = CreatePickup( 1321,Vector( 94.92, -962.1, 29.18 ) );
local BLUEFLAG = CreatePickup( 1321,Vector( 54.44, -566.3, 26.15 ) );
CreateBlip( BLIP_8BALL, 94.92, -962.1, 29.18  );
CreateBlip( BLIP_8BALL, 54.44, -566.3, 26.15  );
MessagePlayer( "Welcome to the server!", player, 255, 0, 0 );
return 1;
}
function onPickupPickedUp( pPlayer, pPickup )
{
if (pPickup.ID == REDFLAG) // || Team == Blue
{
MessagePlayer( "blah", pPlayer, 255, 0, 0 );
//CreateCheckpoint(0,0,0, 5.0,[BLUE]);

}
else if (pPickup.ID == BLUEFLAG) //|| Team == Blue
{
MessagePlayer("BLAH", pPlayer, 255,0,0);
//CreateCheckpoint(0,0,0, 5.0);
}
return 1;
}
function onPlayerEnterCheckpoint( Player, cp )
{
cp.Remove();
}

Thijn

  • Tester
  • Sr. Member
  • ****
  • Posts: 531
  • Karma: +27/-16
    • View Profile
Re: Help on ctf script
« Reply #1 on: August 16, 2011, 10:46:47 am »
You don't have to create those pickups and blips every time someone connects.
Adding it on ScriptLoad is fine.

Also, You're using local REDFLAG, which means the variable can only be accessed within the function or signal.
Using the following it will make a global variable which can be accessed from allover your script.
Code: [Select]
REDFLAG <- CreatePickup( 1321,Vector( 94.92, -962.1, 29.18 ) );
Same goes for the blips.

Then, Your PickedUp signal. There is only 1 thing wrong there.
You're using pPickup.ID (Which is good!) but then comparing it to REDFLAG, which is firstly undefined since it was a local variable, and second its does not return the ID but the instance.
So, Using REDFLAG.ID should work.

Code should be like this, But I didn't tested any of it:
Code: [Select]
function onScriptLoad( )
{
REDFLAG <- CreatePickup( 1321,Vector( 94.92, -962.1, 29.18 ) );
BLUEFLAG <- CreatePickup( 1321,Vector( 54.44, -566.3, 26.15 ) );
CreateBlip( BLIP_8BALL, 94.92, -962.1, 29.18  );
CreateBlip( BLIP_8BALL, 54.44, -566.3, 26.15  );

print( "Script loaded, And pickups & Blips added." );

return 1;
}
function onPlayerConnect(player)
{
MessagePlayer( "Welcome to the server!", player, 255, 0, 0 );
return 1;
}
function onPickupPickedUp( pPlayer, pPickup )
{
if (pPickup.ID == REDFLAG.ID) // || Team == Blue
{
MessagePlayer( "blah", pPlayer, 255, 0, 0 );
//CreateCheckpoint(0,0,0, 5.0,[BLUE]);

}
else if (pPickup.ID == BLUEFLAG.ID) //|| Team == Blue
{
MessagePlayer("BLAH", pPlayer, 255,0,0);
//CreateCheckpoint(0,0,0, 5.0);
}
return 1;
}
function onPlayerEnterCheckpoint( Player, cp )
{
cp.Remove();

return 1;
}

Tommy_Kills

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Help on ctf script
« Reply #2 on: August 17, 2011, 05:29:32 pm »
Thank you it finally worked  ;D ;D ;D

 

© Liberty Unleashed Team.