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); } } }
//At your global variables
new HasPlayerUserGarageCommand[MAX_PLAYERS];
//Under OnPlayerConnect
HasPlayerUserGarageCommand[MAX_PLAYERS] = 0;
//When the played uses the command
if(HasPlayerUserGarageCommand[playerid] == 0)
{
HasPlayerUserGarageCommand[playerid] = 1;
SetTimerEx("GarageCommandCooldown", YourTimerInMilliseconds, false, "i", playerid);
//Garage stuff here
}
else return SendClientMessage(playerid, PutYourOwnColourHere, "Put your message here");
//Somewhere in your script
forward GarageCommandCooldown(playerid);
public GarageCommandCooldown(playerid)
{
HasPlayerUserGarageCommand[playerid] = 0;
return 1;
}
pawn Код:
|
I don't understand what's the HasPlayerUserGarageCommand is for.
|
House.pwn(722) : error 032: array index out of bounds (variable "H148GarageCool") House.pwn(1020) : error 001: expected token: ";", but found "forward" House.pwn(1138) : warning 215: expression has no effect House.pwn(1138) : error 001: expected token: ";", but found ")" House.pwn(1138) : error 029: invalid expression, assumed zero House.pwn(1167) : error 029: invalid expression, assumed zero House.pwn(1167) : warning 215: expression has no effect House.pwn(1167) : error 001: expected token: ";", but found "return" House.pwn(1173) : error 021: symbol already defined: "H148GarageCool" House.pwn(1174) : error 021: symbol already defined: "H148GarageCool" House.pwn(1177) : error 010: invalid function or declaration
House.pwn(722) : error 032: array index out of bounds (variable "HasPlayerUserGarageCommand") House.pwn(1145) : error 002: only a single statement (or expression) can follow each "case" House.pwn(1145) : error 017: undefined symbol "string" House.pwn(1145) : warning 215: expression has no effect House.pwn(1145) : error 001: expected token: ";", but found "]" House.pwn(1145) : fatal error 107: too many error messages on one line
HasPlayerUserGarageCommand[MAX_PLAYERS] = 0;
new string[128];
CMD:garage(playerid, params[]) { new Float: x, Float: y, Float: z; GetDynamicObjectPos(H148Gate, x, y, z); if(IsPlayerInRangeOfPoint(playerid, 30, x, y, z)) { if(HasPlayerUserGarageCommand[playerid] == 0) { HasPlayerUserGarageCommand[playerid] = 1; SetTimerEx("GarageCommandCooldown", 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); } } } } else return SendClientMessage(playerid, -1, "The garage is already moving. Wait to open/close it again."); } return 1; } forward GarageCommandCooldown(playerid); public GarageCommandCooldown(playerid) { HasPlayerUserGarageCommand[playerid] = 0; return 1; }
//Under OnPlayerConnect
HasPlayerUserGarageCommand[playerid] = 0;
pawn Код:
|