15.09.2017, 11:59
The loose indentation warnings are because of the formatting.
I messed up by placing a statement outside a case within the switch statement.
Move the line lastGift[playerid] = gettime() + 10800; below the bracket out of the switch statement.
The correct code should look like this.
I messed up by placing a statement outside a case within the switch statement.
Move the line lastGift[playerid] = gettime() + 10800; below the bracket out of the switch statement.
The correct code should look like this.
PHP код:
#include<a_samp>
#include<zcmd>
public OnFilterScriptInit()
{
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
new lastGift[MAX_PLAYERS];
COMMAND:getgift(playerid, params[])
{
if(gettime() < lastGift[playerid])
{
new str[128];
new timeLeft = lastGift[playerid] - gettime();
format(str, sizeof(str), "You can get another gift in %d hours and %d minutes.", timeLeft / 60, timeLeft % 60);
SendClientMessage(playerid, -1, str);
return 1;
}
switch(random(3))
{
case 0:
{
GivePlayerMoney(playerid, 200);
SendClientMessage(playerid, -1, "You opened a give and received $200.");
}
case 1:
{
GivePlayerMoney(playerid, 500);
SendClientMessage(playerid, -1, "You opened a gift and received $500");
}
case 2:
{ SetPlayerScore(playerid, GetPlayerScore(playerid)+2);
SendClientMessage(playerid, -1, "You opened a gift and received score.");
}
}
lastGift[playerid] = gettime() + 10800;
return 1;
}