Hi, I'm trying to script a garage and i want to create a cooldown timer for the command. If anyone could please help, I'd appreciate it. Note: I am fairly new to scripting and only use scripting for mapping.
Here is the garage code:
Here is the garage code:
Code:
CMD:garage(playerid, params[])
{
new Float: x, Float: y, Float: z;
GetDynamicObjectPos(H148Gate, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 30, x, y, z))
{
if(H148GarageWait == 1)
{
SetTimerEx("H148GarageWait", 2500, false, "i", playerid);
{
switch(H148GarageOpen)
{
case 0:
{
H148GarageOpen = 1;
new string[128];
format(string, sizeof(string), "* %s uses their remote to open the garage.", GetName(playerid));
NearByMessage(playerid, 0x9A2EFEFF, string);
MoveDynamicObject(H148Garage, 1656.53455, 2575.88188, 12.24580, 0.5, 0.00000, -90.00000, 90.00000);
MoveDynamicObject(H148GarageCol1, 1657.35132, 2576.01870, 12.25530, 0.5, 0.00000, -90.00000, 90.00000);
MoveDynamicObject(H148GarageCol2, 1655.71033, 2576.01870, 12.25530, 0.5, 0.00000, -90.00000, 90.00000);
H148GarageSound1(playerid);
}
case 1:
{
H148GarageOpen = 0;
new string[128];
format(string, sizeof(string), "* %s uses their remote to close the garage.", GetName(playerid));
NearByMessage(playerid, 0x9A2EFEFF, string);
MoveDynamicObject(H148Garage, 1656.53455, 2576.24587, 11.12580, 0.5, 0.00000, 0.00000, 90.00000);
MoveDynamicObject(H148GarageCol1, 1657.35132, 2576.29858, 11.61530, 0.5, 0.00000, 0.00000, 90.00000);
MoveDynamicObject(H148GarageCol2, 1655.71033, 2576.29858, 11.61530, 0.5, 0.00000, 0.00000, 90.00000);
H148GarageSound1(playerid);
}
}
}
}
}
return 1;
}
forward H148GarageSound1(playerid);
public H148GarageSound1(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 30, 1656.4711, 2576.2517, 10.8535))
{
PlayerPlaySound(i, 1153, 1656.4711, 2576.2517, 10.8535);
SetTimerEx("H148GarageSound2", 2000, false, "i", playerid);
}
}
}
forward H148GarageSound2(playerid);
public H148GarageSound2(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerInRangeOfPoint(i, 30, 1656.4711, 2576.2517, 10.8535))
{
PlayerPlaySound(i, 1154, 1656.4711, 2576.2517, 10.8535);
}
}
}
Aucun commentaire:
Enregistrer un commentaire