21.04.2015, 22:02
Код:
dcmd_takedrugs(playerid, params[]) { if (PlayerInfo[playerid][pSpawn] == 1){ if (PlayerInfo[playerid][pTeam] == TEAM_CIVILIAN && PlayerInfo[playerid][pVigilante] == 0){ new idx,amount,string[256],tmp[256]; tmp = strtok(params, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_ERROR, "USAGE: /takedrugs (qty)."); return 1; } if(!isNumeric(tmp)) { SendClientMessage(playerid, COLOR_ERROR, "Invalid Amount."); return 1; } amount = strval(tmp); if (PlayerInfo[playerid][pDrugs] < amount) { format(string, sizeof(string), "You Do Not Have Enough Drugs. You Are Carrying %d Grams Of Drugs.",PlayerInfo[playerid][pDrugs]); SendClientMessage(playerid,COLOR_ERROR, string); return 1; } if (amount < 1 || amount > 200) { format(string, sizeof(string), "Invalid Drug Quantity. Enter an Amount of Grams of Drugs to Take Between 1 and 200. (Carrying %d Grams)",PlayerInfo[playerid][pDrugs]); SendClientMessage(playerid, COLOR_ERROR, string); return 1; } SetPlayerSpecialAction(playerid,SPECIAL_ACTION_SMOKE_CIGGY); PlayerInfo[playerid][pDrugs] -= amount; PlayerInfo[playerid][pDrugTime] = amount * 10; SendClientMessage(playerid,COLOR_SERVER_HELP_MSG, "You Are On Drugs. Your Health Will Refill Automatically."); GameTextForPlayer(playerid,"~w~ON DRUGS",5000,3); if (IsSuspectInRangeOfPolice(playerid) && PlayerInfo[playerid][pJailed] == 0) { format(string, sizeof(string), "Crime: Drug Consumption"); ReportCrimeTOPolice(playerid,string); PlayerInfo[playerid][pWantedLevel] ++; } SetPlayerWantedStats(playerid,"Drug Consumption"); }else{ SendClientMessage(playerid, COLOR_ERROR, "Law Enforcement Agents Cannot Take Drugs."); } }else{ SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command When You're Dead."); } return 1; }