29.09.2014, 16:48
/smokeweed is working even when the player has no weed.. Even if an admin only gives the player 1 gram or so, they can still /smokeweed. They can also keep using /smokeweed even when their health is above 75? Please help me.
Thanks!
Edit: No errors or warning in the script
Also got
Thanks!
pawn Код:
GetPlayerWeed(playerid) return Weed[playerid];
CMD:agiveweed(playerid, params[])
{
new targetid, string[128], amount;
if(PlayerStat[playerid] [AdminLevel] < 2) return SendClientMessage(playerid, GREY, "You don't have access to this command!");
if(sscanf(params, "ud[128]", targetid, amount)) return SendClientMessage(playerid, GREY, "USAGE: /agiveweed [playerid] [amount]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, GREY, "That player is not connected!");
{
GetPlayerWeed(playerid);
Weed[targetid] = amount+1;
format(string, sizeof(string), "You have given %s %d gram(s) of weed!", GetOOCName(targetid), amount);
SendClientMessage(playerid, WHITE, string);
format(string, sizeof(string), "Administrator %s has given you %d gram(s) of weed!", GetOOCName(playerid), amount);
SendClientMessage(targetid, WHITE, string);
AdminActionLog(string);
}
return 1;
}
CMD:smokeweed(playerid, params[])
{
if(GetPlayerWeed(playerid) < 1 ) return SendClientMessage(playerid, WHITE, "You don't have any weed left!");
{
new Float:health;
if(GetPlayerHealth(playerid, health) > 75) return SendClientMessage(playerid, WHITE, "You cannot smoke weed if your health is above 75!");
{
new string[128];
ApplyAnimation(playerid, "JST_BUISNESS", "smoke_01", 4.1, 1, 1, 1, 0, 1, 1);
SetPlayerHealth(playerid, health+25);
format(string, sizeof(string), "%s takes out a joint and smokes some weed.", GetOOCName(playerid));
SendNearByMessage(playerid, ACTION_COLOR, string, 4);
}
}
return 1;
}
Also got
pawn Код:
new Weed[MAX_PLAYERS];
// and
Weed[playerid] = 0;