Advertisement
BlooDMasK

Untitled

Jul 6th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. #define DIALOG_VENDIH 2017//droga
  2.  
  3.  
  4. enum HVendi
  5. {
  6. IDH, //nel comando diventa l'id di colui che riceverà il dialog
  7. Venditore, //nel dialog diventa colui che ha eseguito il comando
  8. Grammi,
  9. Prezzo
  10. }
  11. new hVendi[MAX_PLAYERS][HVendi];
  12.  
  13.  
  14.  
  15. CMD:dvendi(playerid, params[]){
  16. if(PlayerInfo[playerid][pHashish] == 0) return SCM(playerid, ROSSO, "Devi produrre/acquistare qualche grammo prima di poter vendere!");
  17. new string[500], Float:X, Float:Y, Float:Z;
  18. hVendi[playerid][Venditore] = playerid; //setta la variabile venditore = al playerid in questione (colui che fa il comando)
  19. GetPlayerPos(hVendi[playerid][IDH], X, Y, Z);
  20. if(!IsPlayerInRangeOfPoint(playerid, 4.0, X, Y, Z)) return SCM(playerid, ROSSO, "Devi essere vicino al player!");
  21. 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)]");
  22. if(hVendi[playerid][IDH] == INVALID_PLAYER_ID) return SCM(hVendi[playerid][Venditore], ROSSO, "ID inesistente!");
  23. if(hVendi[playerid][IDH] == hVendi[playerid][Venditore]) return SCM(hVendi[playerid][Venditore], ROSSO, "Non puoi venderti la droga!");
  24. if(hVendi[playerid][Prezzo] < 300 || hVendi[playerid][Prezzo] > 500) return SCM(hVendi[playerid][Venditore], ROSSO, "Il prezzo deve essere compreso tra 300$ e 500$!");
  25. if(hVendi[playerid][Grammi] < 1 || hVendi[playerid][Grammi] > 10) return SCM(hVendi[playerid][Venditore], ROSSO, "Puoi vendere solo da 1g a 10g!");
  26. 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]);
  27. ShowPlayerDialog(hVendi[playerid][IDH], DIALOG_VENDIH, DIALOG_STYLE_MSGBOX, ""COL_TITLES"Vendi Droga",string,"Compra","Rifiuta");
  28. SCM(playerid, GIALLO, "In attesa di una risposta dal player...");
  29. return 1;}
  30.  
  31.  
  32. //ONDIALOGRESPONSE
  33. if(dialogid == DIALOG_VENDIH){
  34. if(!response) return SCM(hVendi[playerid][Venditore], ROSSO, "Il cliente ha rifiutato l'offerta!");
  35. if(response){
  36. if(PlayerInfo[playerid][pSoldi] < hVendi[playerid][Prezzo]) return SCM(hVendi[playerid][Venditore], ROSSO, "Il cliente non ha i soldi sufficienti per accettare l'offerta!");
  37. SCM(hVendi[playerid][Venditore], ROSSO, "Il cliente ha accettato l'offerta!"); //messaggio al venditore
  38. GivePlayerMoney(hVendi[playerid][Venditore], hVendi[playerid][Prezzo]); // da i soldi al venditore
  39. GivePlayerMoney(playerid, -hVendi[playerid][Prezzo]); //toglie i soldi a colui che clicca "response"
  40. PlayerInfo[playerid][pHashish] = PlayerInfo[playerid][pHashish] + hVendi[playerid][Grammi]; //da i grammi a colui che clicca "response"
  41. PlayerInfo[hVendi[playerid][Venditore]][pHashish] = hVendi[playerid][Grammi]; //toglie i grammi al venditore
  42. SCM(playerid, GIALLO, "Hai accettato l'offerta!");
  43. hVendi[playerid][Venditore] = 0; }} //resetta la variabile
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement