Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <YSI\y_ini>
- // Defining the path where the user accounts will go
- #define PATH "/Drugger/%s.ini"
- // Some configurations for the script to work
- new HasMaterials[MAX_PLAYERS];
- new IsDrunk[MAX_PLAYERS];
- new lightblue = 0xADD8E6FF;
- new red = 0xFF0000AA;
- // Defining the user Information script-related
- enum pInfo
- {
- pJob,
- pDrugs
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- forward LoadUser_data(playerid,name[],value[]);
- public LoadUser_data(playerid,name[],value[])
- {
- INI_Int("IsDrugger",PlayerInfo[playerid][pJob]);
- INI_Int("AmountOfDrugs",PlayerInfo[playerid][pDrugs]);
- return 1;
- }
- stock UserPath(playerid)
- {
- new string[128],playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername, sizeof(playername));
- format(string, sizeof(string), PATH, playername);
- return string;
- }
- /*Credits to Dracoblue*/
- stock udb_hash(buf[]) {
- new length=strlen(buf);
- new s1 = 1;
- new s2 = 0;
- new n;
- for (n=0; n<length; n++)
- {
- s1 = (s1 + buf[n]) % 65521;
- s2 = (s2 + s1) % 65521;
- }
- return (s2 << 16) + s1;
- }
- public OnFilterScriptInit()
- {
- // Takejob configurations
- CreatePickup(1239, 1, 2065.2837,-1558.5857,13.4369, -1);
- Create3DTextLabel("Drugger job\n/takedruggerjob | /quitdruggerjob", 0xFF0000AA, 2065.2837,-1558.5857,13.4369, 5.0, 0, 0);
- // pickupmaterials configurations
- CreatePickup(1254, 1, 2067.4619, -1561.9774, 13.4270, -1);
- Create3DTextLabel("Drugger job\n/pickupmaterials", 0xFF0000AA, 2067.4619,-1561.9774,13.4270, 5.0, 0, 0);
- // createdrugs configurations
- CreatePickup(1279, 1, 2355.3733, -648.4775, 128.0547, -1);
- Create3DTextLabel("Drugger job\n/createdrugs", 0xFF0000AA, 2355.3733, -648.4775, 128.0547, 5.0, 0, 0);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- COMMAND:takedruggerjob(playerid, params[])
- {
- if(PlayerInfo[playerid][pJob] == 0)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.0, 2065.2837, -1558.5857, 13.4369))
- {
- PlayerInfo[playerid][pJob] = 1;
- SendClientMessage(playerid, lightblue, "Congratulations. You're now an Drugger. For more help about your job please use '/druggerhelp'.");
- }
- else
- SendClientMessage(playerid, red, "[ERROR] You're not at the place to take the Drugger job.");
- }
- else
- SendClientMessage(playerid, red, "[ERROR] You're already an Drugger.");
- return 1;
- }
- COMMAND:quitdruggerjob(playerid, params[])
- {
- if(PlayerInfo[playerid][pJob] == 1)
- {
- SendClientMessage(playerid, lightblue, "You left your drugger job.");
- PlayerInfo[playerid][pJob] = 0;
- }
- else
- SendClientMessage(playerid, red, "[ERROR] You're not an drugger.");
- return 1;
- }
- COMMAND:druggerhelp(playerid, params[])
- {
- new msg[2000];
- format(msg, 2000, "%s{FFFFFF}Hello Drugger,\n\n\n", msg);
- format(msg, 2000, "%s{FFFFFF}These are the commands of your job:\n\n", msg);
- format(msg, 2000, "%s{FF0000}1. {FFFFFF}/takedruggerjob -> Takes the Drugger job\n", msg);
- format(msg, 2000, "%s{FF0000}2. {FFFFFF}/pickupmaterials -> Picks up the required materials for creating drugs\n", msg);
- format(msg, 2000, "%s{FF0000}3. {FFFFFF}/quitdruggerjob -> Quits the Drugger job\n", msg);
- format(msg, 2000, "%s{FF0000}4. {FFFFFF}/createdrugs -> Creates drugs\n", msg);
- format(msg, 2000, "%s{FF0000}5. {FFFFFF}/givedrugs -> You can trade drugs for cash with other players near you\n", msg);
- format(msg, 2000, "%s{FF0000}6. {FFFFFF}/usedrugs -> You can use the drugs you got\n", msg);
- format(msg, 2000, "%s{FF0000}7. {FFFFFF}/mydrugs -> Checks if you got drugs or not\n\n", msg);
- format(msg, 2000, "%s{FFFFFF}Thank you for reading the help menu", msg);
- if(PlayerInfo[playerid][pJob] == 1)
- {
- ShowPlayerDialog(playerid, 5678, DIALOG_STYLE_MSGBOX, "{FFFFFF}Drugger Help", msg, "Okay", "");
- return 1;
- }
- else
- SendClientMessage(playerid, red, "[ERROR] You're not an Drugger.");
- return 1;
- }
- COMMAND:pickupmaterials(playerid, params[])
- {
- if(PlayerInfo[playerid][pJob] == 1)
- {
- if(HasMaterials[playerid] == 0)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.0, 2067.4619,-1561.9774,13.4270))
- {
- HasMaterials[playerid] = 1;
- SendClientMessage(playerid, lightblue, "You have loaded the materials successfully. Take care of police.");
- SetPlayerCheckpoint(playerid, 2355.3733, -648.4775, 128.0547, 1.0);
- }
- else
- SendClientMessage(playerid, red, "[ERROR] You're not at the materials pickup position.");
- }
- else
- SendClientMessage(playerid, red, "[ERROR] You can only load 1 pack of materials at one time.");
- }
- else
- SendClientMessage(playerid, red, "[ERROR] You're not a Drugger.");
- }
- COMMAND:createdrugs(playerid, params[])
- {
- if(PlayerInfo[playerid][pJob] == 1)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.0, 2355.3733, -648.4775, 128.0547))
- {
- PlayerInfo[playerid][pDrugs]++;
- SendClientMessage(playerid, lightblue, "Congratulations. You've created drugs.");
- }
- else
- SendClientMessage(playerid, red, "[ERROR] You're not at the drugs creation place.");
- }
- else
- SendClientMessage(playerid, red, "[ERROR] You're not an Drugger.");
- }
- COMMAND:usedrugs(playerid, params[])
- {
- if(PlayerInfo[playerid][pDrugs] >= 1)
- {
- PlayerInfo[playerid][pDrugs]--;
- IsDrunk[playerid] = 1;
- SetPlayerDrunkLevel(playerid, 50000);
- SendClientMessage(playerid, lightblue, "You're now under effects of drugs. Be sure the cops wont bust you.");
- SetTimer("drunkmiddle", 150000, false);
- }
- else
- SendClientMessage(playerid, red, "[ERROR] You don't have drugs. Ask someone who has it to give it to you.");
- }
- forward drunkmiddle(playerid);
- public drunkmiddle(playerid)
- {
- SendClientMessage(playerid, lightblue, "You've slowly recovering your self from the drugs.");
- SetPlayerDrunkLevel(playerid, 55000);
- SetTimer("drunkend", 360000, false);
- return 1;
- }
- forward drunkend(playerid);
- public drunkend(playerid)
- {
- SetPlayerDrunkLevel(playerid, 0);
- SendClientMessage(playerid, lightblue, "You fully recovered your self from the drugs.");
- IsDrunk[playerid] = 0;
- return 1;
- }
- COMMAND:mydrugs(playerid, params[])
- {
- new string[256];
- if(PlayerInfo[playerid][pDrugs] >= 1)
- {
- format(string, 256, "Drugs in your bag: %i", PlayerInfo[playerid][pDrugs]);
- SendClientMessage(playerid, lightblue, string);
- }
- else if(PlayerInfo[playerid][pDrugs] < 1)
- {
- SendClientMessage(playerid, lightblue, "You don't have any drugs in your bag.");
- }
- return 1;
- }
- COMMAND:givedrugs(playerid, params[])
- {
- new OtherPlayer, OtherPlayerName[24], msg[2000], YourName[24];
- new Float:x, Float:y, Float:z;
- GetPlayerPos(playerid, x, y, z);
- if(PlayerInfo[playerid][pDrugs] >= 1)
- {
- if(IsPlayerInRangeOfPoint(OtherPlayer, 2.0, x, y, z))
- {
- GetPlayerName(OtherPlayer, OtherPlayerName, sizeof(OtherPlayerName));
- GetPlayerName(playerid, YourName, sizeof(YourName));
- PlayerInfo[OtherPlayer][pDrugs]++;
- PlayerInfo[OtherPlayer][pDrugs]--;
- format(msg, 2000, "You've sent drugs to %s.", OtherPlayerName);
- SendClientMessage(playerid, lightblue, msg);
- format(msg, 2000, "You've recieved drugs from %s.", YourName);
- SendClientMessage(OtherPlayer, lightblue, msg);
- }
- else
- SendClientMessage(playerid, red, "[ERROR] You're not near that person.");
- }
- else
- SendClientMessage(playerid, red, "[ERROR] You can't send drugs you don't own.");
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- DisablePlayerCheckpoint(playerid);
- return 1;
- }
- // Saving everything when player get's dissconected.
- public OnPlayerDisconnect(playerid, reason)
- {
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"IsDrugger",PlayerInfo[playerid][pJob]);
- INI_WriteInt(File,"AmountOfDrugs",PlayerInfo[playerid][pDrugs]);
- INI_Close(File);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- if(fexist(UserPath(playerid)))
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- }
- else
- {
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"IsDrugger", 0);
- INI_WriteInt(File,"AmountOfDrugs",0);
- INI_Close(File);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement