Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define DIALOG_DRUGHELP 1069
- #define COLOR_GREY 0xAFAFAFAA
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- new DrugTimer[MAX_PLAYERS];
- new StonedTimer[MAX_PLAYERS];
- new UsedDrug[MAX_PLAYERS];
- enum pInfo{
- pCannabis,
- pCocaine
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- forward RemoveDrugEffect(playerid);
- public RemoveDrugEffect(playerid)
- {
- SetPlayerWeather(playerid, 0);
- SetPlayerDrunkLevel(playerid, 0);
- SendClientMessage(playerid, COLOR_GREY, "Your drug effect has been removed, you may /usedrug again.");
- return 1;
- }
- stock pName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, name, sizeof(name));
- return name;
- }
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Simple Drug System by: Shadow");
- print(" If you like this system, +rep would be appreciated.");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- DrugTimer[playerid] = 0;
- StonedTimer[playerid] = 0;
- UsedDrug[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- DrugTimer[playerid] = 0;
- StonedTimer[playerid] = 0;
- UsedDrug[playerid] = 0;
- return 1;
- }
- CMD:drughelp(playerid, params[])
- {
- if(IsPlayerAdmin(playerid)) ShowPlayerDialog(playerid, DIALOG_DRUGHELP, DIALOG_STYLE_MSGBOX, "Drug Help", "/mydrugs - Check your drugs.\n/usedrug - Use a drug.\n/givedrugs - Give someone X amount of drug", "Close", "");
- else ShowPlayerDialog(playerid, DIALOG_DRUGHELP, DIALOG_STYLE_MSGBOX, "Drug Help", "/mydrugs - Check your drugs.\n/usedrug - Use a drug.", "Close", "");
- return 1;
- }
- CMD:mydrugs(playerid, params[])
- {
- new str[150];
- format(str, sizeof(str), "{FFFFFF}%s drugs", pName(playerid));
- SendClientMessage(playerid, COLOR_GREY, str);
- format(str, sizeof(str), "{42C5F4}Cannabis: {FFFFFF}(%d grams) {42C5F4}Cocaine: {FFFFFF}(%d grams)", PlayerInfo[playerid][pCannabis], PlayerInfo[playerid][pCocaine]);
- SendClientMessage(playerid, COLOR_GREY, str);
- return 1;
- }
- CMD:usedrug(playerid, params[])
- {
- new option[200], Float:HP, str[250], Float:AHP;
- if(sscanf(params, "s[200] ", option))
- {
- SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/usedrug [Drug]");
- SendClientMessage(playerid, COLOR_GREY, "Drugs: Cannabis, Cocaine");
- return 1;
- }
- if(strcmp(option, "cannabis", true) == 0)
- {
- if(gettime() < (DrugTimer[playerid] + 5))
- {
- format(str, sizeof(str), "You have to wait %d seconds before you can use /usedrug cannabis again!", (DrugTimer[playerid] + 5) - gettime());
- SendClientMessage(playerid, COLOR_GREY, str);
- return 1;
- }
- if(gettime() < (StonedTimer[playerid] + 120))
- {
- format(str, sizeof(str), "You have to wait %d seconds before you can use /usedrug cannabis again!", (StonedTimer[playerid] + 120) - gettime());
- SendClientMessage(playerid, COLOR_GREY, str);
- return 1;
- }
- GetPlayerHealth(playerid, Float:HP);
- if(PlayerInfo[playerid][pCannabis] < 1) return SendClientMessage(playerid, COLOR_GREY, "You do not have that much of Cannabis.");
- if(HP >= 100) return SendClientMessage(playerid, COLOR_GREY, "Your HP is already full!");
- if(HP >= 90)
- {
- SetPlayerHealth(playerid, 100);
- }
- else if(HP < 90)
- {
- SetPlayerHealth(playerid, HP+15);
- }
- SendClientMessage(playerid, COLOR_GREY, "You've used 2 grams of cannabis and recived +15 health");
- SetPlayerWeather(playerid, 2009);
- SetPlayerDrunkLevel(playerid, 9000);
- PlayerInfo[playerid][pCannabis] -=1;
- DrugTimer[playerid] = gettime();
- UsedDrug[playerid] ++;
- if(UsedDrug[playerid] >= 3)
- {
- SetTimerEx("RemoveDrugEffect", 60000*2, false, "i", playerid);
- UsedDrug[playerid] = 0;
- StonedTimer[playerid] = gettime();
- }
- return 1;
- }
- if(strcmp(option, "cocaine", true) == 0)
- {
- if(gettime() < (DrugTimer[playerid] + 5))
- {
- format(str, sizeof(str), "You have to wait %d seconds before you can use /usedrug cocaine again!", (DrugTimer[playerid] + 5) - gettime());
- SendClientMessage(playerid, COLOR_GREY, str);
- return 1;
- }
- if(gettime() < (StonedTimer[playerid] + 120))
- {
- format(str, sizeof(str), "You have to wait %d seconds before you can use /usedrug cocaine again!", (StonedTimer[playerid] + 120) - gettime());
- SendClientMessage(playerid, COLOR_GREY, str);
- return 1;
- }
- GetPlayerArmour(playerid, Float:AHP);
- if(PlayerInfo[playerid][pCocaine] < 1) return SendClientMessage(playerid, COLOR_GREY, "You do not have that much of Cocaine.");
- if(AHP >= 100) return SendClientMessage(playerid, COLOR_GREY, "Your Armor is already full!");
- if(AHP >= 90)
- {
- SetPlayerArmour(playerid, 100);
- }
- else if(AHP < 90)
- {
- SetPlayerArmour(playerid, AHP+15);
- }
- SendClientMessage(playerid, COLOR_GREY, "You've used 2 grams of cocaine and recived +15 armour");
- SetPlayerWeather(playerid, 250);
- SetPlayerDrunkLevel(playerid, 9000);
- PlayerInfo[playerid][pCocaine] -=1;
- DrugTimer[playerid] = gettime();
- UsedDrug[playerid] ++;
- if(UsedDrug[playerid] >= 3)
- {
- SetTimerEx("RemoveDrugEffect", 60000*2, false, "i", playerid);
- UsedDrug[playerid] = 0;
- StonedTimer[playerid] = gettime();
- }
- return 1;
- }
- return 1;
- }
- CMD:givedrugs(playerid, params[])
- {
- new option[200], id, amount, str[100], Float:x, Float:y, Float:z;
- GetPlayerPos(id, Float:x, Float:y, Float:z);
- if(sscanf(params, "s[200] ", option))
- {
- SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/givedrugs [drug]");
- SendClientMessage(playerid, COLOR_GREY, "Drugs: Cannabis, Cocaine");
- return 1;
- }
- if(strcmp(option, "cannabis", true) == 0)
- {
- if(sscanf(params, "s[200]dd", option, id, amount))
- {
- SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/givedrugs cannabis [playerid] [amount]");
- return 1;
- }
- if(!(IsPlayerInRangeOfPoint(playerid, 3.0, Float:x, Float:y, Float:z))) return SendClientMessage(playerid, COLOR_GREY, "You're not in range of that player!");
- format(str, sizeof(str), "You've given %s %d of cannabis!",pName(id), amount);
- SendClientMessage(playerid, COLOR_GREY, str);
- PlayerInfo[id][pCannabis] += amount;
- PlayerInfo[playerid][pCannabis] -= amount;
- return 1;
- }
- if(strcmp(option, "cocaine", true) == 0)
- {
- if(sscanf(params, "s[200]dd", option, id, amount))
- {
- SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/givedrugs cocaine [playerid] [amount]");
- return 1;
- }
- if(!(IsPlayerInRangeOfPoint(playerid, 3.0, Float:x, Float:y, Float:z))) return SendClientMessage(playerid, COLOR_GREY, "You're not in range of that player!");
- format(str, sizeof(str), "You've given %s %d of cocaine!",pName(id), amount);
- SendClientMessage(playerid, COLOR_GREY, str);
- PlayerInfo[id][pCocaine] += amount;
- PlayerInfo[playerid][pCocaine] -= amount;
- return 1;
- }
- return 1;
- }
- CMD:agivedrugs(playerid, params[])
- {
- new option[200], id, amount, str[100];
- if(!(IsPlayerAdmin(playerid))) return SendClientMessage(playerid, COLOR_GREY, "Not authorized!");
- if(sscanf(params, "s[200] ", option))
- {
- SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/agivedrugs [drug]");
- SendClientMessage(playerid, COLOR_GREY, "Drugs: Cannabis, Cocaine");
- return 1;
- }
- if(strcmp(option, "cannabis", true) == 0)
- {
- if(sscanf(params, "s[200]dd", option, id, amount))
- {
- SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/agivedrugs cannabis [playerid] [amount]");
- return 1;
- }
- format(str, sizeof(str), "You've given %s %d of cannabis!",pName(id), amount);
- SendClientMessage(playerid, COLOR_GREY, str);
- PlayerInfo[id][pCannabis] += amount;
- return 1;
- }
- if(strcmp(option, "cocaine", true) == 0)
- {
- if(sscanf(params, "s[200]dd", option, id, amount))
- {
- SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/agivedrugs cocaine [playerid] [amount]");
- return 1;
- }
- format(str, sizeof(str), "You've given %s %d of cocaine!",pName(id), amount);
- SendClientMessage(playerid, COLOR_GREY, str);
- PlayerInfo[id][pCocaine] += amount;
- return 1;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement