CMD:usecoca(playerid, params[]) { if(PlayerInfo[playerid][Cocaine] >=2) { SendClientMessage(playerid, -1, "you just used 2 grams of cocaine restored 20 hp"); PlayerInfo[playerid][Cocaine] -= 2; //too stoned fix 2moro new Float:health; GetPlayerHealth(playerid,health); if (health < 100) { SetPlayerHealth(playerid, health +15); } else if(health == 100) { SendClientMessage(playerid, -1, "why use coca"); } } else SendClientMessage(playerid, -1, "you dont have enough coca"); return 1; }
CMD:usecoca(playerid, params[]) { if(PlayerInfo[playerid][Cocaine] >=2) { new Float:health; GetPlayerHealth(playerid,health); if (health < 100) { SetPlayerHealth(playerid, health +15); PlayerInfo[playerid][Cocaine] -= 2; SendClientMessage(playerid, -1, "you just used 2 grams of cocaine restored 20 hp"); } else if(health == 100) { SendClientMessage(playerid, -1, "why use coca"); } } else SendClientMessage(playerid, -1, "you dont have enough coca"); return 1; }
public OnGameModeInit() { SetTimer("SpawnVehicle", 10000, false); // spawns vehicle after 10 seconds you can use this line in a command } forward SpawnVehicle(); public SpawnVehicle() { CreateVehicle(520, 2109.1763, 1503.0453, 32.2887, 82.2873, -1, -1, 60); /// add your vehicles here }
you was sending the message of "you just used..." and PlayerInfo[playerid][Cocaine] -= 2; before checking the health thats why no matter whats your health is you will get the message and minus 2 cocaine as long you have 2 or more cocaine
use this: Код:
CMD:usecoca(playerid, params[]) { if(PlayerInfo[playerid][Cocaine] >=2) { new Float:health; GetPlayerHealth(playerid,health); if (health < 100) { SetPlayerHealth(playerid, health +15); PlayerInfo[playerid][Cocaine] -= 2; SendClientMessage(playerid, -1, "you just used 2 grams of cocaine restored 20 hp"); } else if(health == 100) { SendClientMessage(playerid, -1, "why use coca"); } } else SendClientMessage(playerid, -1, "you dont have enough coca"); return 1; } Код:
public OnGameModeInit() { SetTimer("SpawnVehicle", 10000, false); // spawns vehicle after 10 seconds you can use this line in a command } forward SpawnVehicle(); public SpawnVehicle() { CreateVehicle(520, 2109.1763, 1503.0453, 32.2887, 82.2873, -1, -1, 60); /// add your vehicles here } |
CMD:usecoca(playerid, params[])
{
if(PlayerInfo[playerid][Cocaine] < 2) return SendClientMessage(playerid, -1, "You don't have enough coca.");
new Float:health;
GetPlayerHealth(playerid, health);
if(health >= 100.0) return SendClientMessage(playerid, -1, "Why are you using coca?");
SetPlayerHealth(playerid, ((health + 15.0) >= 100.0) ? (100.0) : (health + 15.0));
SendClientMessage(playerid, -1, "You just used 2 grams of cocaine and restored 20 hp.");
PlayerInfo[playerid][Cocaine] -= 2; //too stoned fix 2moro
return 1;
}
if(pInfo[playerid][job] != 1) return 0; (or) if(!pInfo[playerid][job] == 1) return 0;