Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define DIALOG_VENDIH 2017//droga
- enum HVendi
- {
- IDH, //nel comando diventa l'id di colui che riceverà il dialog
- Venditore, //nel dialog diventa colui che ha eseguito il comando
- Grammi,
- Prezzo
- }
- new hVendi[MAX_PLAYERS][HVendi];
- CMD:dvendi(playerid, params[]){
- if(PlayerInfo[playerid][pHashish] == 0) return SCM(playerid, ROSSO, "Devi produrre/acquistare qualche grammo prima di poter vendere!");
- new string[500], Float:X, Float:Y, Float:Z;
- hVendi[playerid][Venditore] = playerid; //setta la variabile venditore = al playerid in questione (colui che fa il comando)
- GetPlayerPos(hVendi[playerid][IDH], X, Y, Z);
- if(!IsPlayerInRangeOfPoint(playerid, 4.0, X, Y, Z)) return SCM(playerid, ROSSO, "Devi essere vicino al player!");
- if(sscanf(params, "udd", hVendi[playerid][IDH], hVendi[playerid][Prezzo], hVendi[playerid][Grammi])) return SCM(playerid, ROSSO, "Utilizzo:/dvendi [ID] [Prezzo (da 300$ a 500$)] [Grammi (10 max)]");
- if(hVendi[playerid][IDH] == INVALID_PLAYER_ID) return SCM(hVendi[playerid][Venditore], ROSSO, "ID inesistente!");
- if(hVendi[playerid][IDH] == hVendi[playerid][Venditore]) return SCM(hVendi[playerid][Venditore], ROSSO, "Non puoi venderti la droga!");
- if(hVendi[playerid][Prezzo] < 300 || hVendi[playerid][Prezzo] > 500) return SCM(hVendi[playerid][Venditore], ROSSO, "Il prezzo deve essere compreso tra 300$ e 500$!");
- if(hVendi[playerid][Grammi] < 1 || hVendi[playerid][Grammi] > 10) return SCM(hVendi[playerid][Venditore], ROSSO, "Puoi vendere solo da 1g a 10g!");
- format(string,sizeof(string), "%s vuole venderti %d g di Hashish a %d $\n Vuoi Comprare?", hVendi[playerid][Venditore], hVendi[playerid][Grammi], hVendi[playerid][Prezzo]);
- ShowPlayerDialog(hVendi[playerid][IDH], DIALOG_VENDIH, DIALOG_STYLE_MSGBOX, ""COL_TITLES"Vendi Droga",string,"Compra","Rifiuta");
- SCM(playerid, GIALLO, "In attesa di una risposta dal player...");
- return 1;}
- //ONDIALOGRESPONSE
- if(dialogid == DIALOG_VENDIH){
- if(!response) return SCM(hVendi[playerid][Venditore], ROSSO, "Il cliente ha rifiutato l'offerta!");
- if(response){
- if(PlayerInfo[playerid][pSoldi] < hVendi[playerid][Prezzo]) return SCM(hVendi[playerid][Venditore], ROSSO, "Il cliente non ha i soldi sufficienti per accettare l'offerta!");
- SCM(hVendi[playerid][Venditore], ROSSO, "Il cliente ha accettato l'offerta!"); //messaggio al venditore
- GivePlayerMoney(hVendi[playerid][Venditore], hVendi[playerid][Prezzo]); // da i soldi al venditore
- GivePlayerMoney(playerid, -hVendi[playerid][Prezzo]); //toglie i soldi a colui che clicca "response"
- PlayerInfo[playerid][pHashish] = PlayerInfo[playerid][pHashish] + hVendi[playerid][Grammi]; //da i grammi a colui che clicca "response"
- PlayerInfo[hVendi[playerid][Venditore]][pHashish] = hVendi[playerid][Grammi]; //toglie i grammi al venditore
- SCM(playerid, GIALLO, "Hai accettato l'offerta!");
- hVendi[playerid][Venditore] = 0; }} //resetta la variabile
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement