pawn Code:
CMD:camo(playerid, params[])
{
if(UsingCamo == 0) //Checking if the player is using camo. 0 = Not using, 1 = Using
{
if(OnCamoCooldown == 0) //Checking if the player is on the camo cooldown. 0 = not using, 1 using
{
new Vw = randomEx(1,5); //We are setting players world to random (from 1 to 5) so people that are also using camo wont see each other. You can change this 1,5 to anything you want)
SetPlayerVirtualWorld(playerid, Vw); //The player is now entering the camo. We are setting his virtual world to the random defined above it
SetTimerEx("CamoTimer", 10000, false, "i", playerid); //We are making 10 seconds camo usage. When these 10 seconds expire player will be tossed out from the camo.
SetTimerEx("CamoCooldown", 90000, false, "i", playerid); //We are also setting the players cooldown to 90.000 miliseconds which are 90 seconds, aka 3 minutes, you can also change this.
UsingCamo = 1; //We are setting that the player is currently using the camouflage
OnCamoCooldown = 1; //setting the player onto the cooldown.
}
else
{
SendClientMessage(playerid, COLOR_RED, "<!>You are on a cooldown!"); //If the player is on the cooldown this will send him the message that he is and he wont be able to use the command.
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "<!>You are currently using it already!"); //If the player is trying to enter camo and they are already using it
}
return 1;
}
pawn Code:
public CamoCooldown(playerid) //This defines our Camo Cooldown timer, and now we will add what will happen when it ends.
{
SendClientMessage(playerid, COLOR_GREEN, "<!>Your camo timer has expired. You can now use it again!");//We are sending player message that tells him that they are no longer on the cooldown.
OnCamoCooldown = 0; //We are setting the variable to 0 so the player can use the command again.
return 1;
}
public CamoTimer(playerid) //This is what will happen to the player when the Camo expires.
{
SetPlayerVirtualWorld(playerid, 0); //We are returning player to the normal world. World 0, so he can play with others normaly.
UsingCamo = 0; //We are setting this variable to 0 so the player is no longer in the camouflage.
SendClientMessage(playerid, COLOR_GREEN, "<!>Your camo has expired!"); //Sending a simple message saying that they are no longer using the camo.
return 1;
}