Guest User

HG

a guest
Dec 29th, 2009
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.59 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define DIALOG_ID_SKIN_SELECTION    2
  4. #define MAX_SKIN_NAME   32
  5.  
  6. enum skin_layout
  7. {
  8.     skinID,
  9.     skinPrice,
  10.     skinWeapon,
  11.     skinAmmo,
  12.     skinName[MAX_SKIN_NAME],
  13. };
  14.  
  15. new listitems[][skin_layout] =
  16. {
  17.     {120,   1337,   23,     500,    "Man skin"},
  18.     {93,    1500,   23,     500,    "Girl skin"},
  19.     {113,   1500,   23,     500,    "Maffia skin"},
  20.     {59,    1500,   23,     500,    "Man skin"}
  21. };
  22.  
  23. main()
  24. {
  25.     return 1;
  26. }
  27.  
  28. public OnPlayerCommandText(playerid, cmdtext[])
  29. {
  30.     if(strcmp(cmdtext, "/riided", true) == 0)
  31.     {
  32.         new fullstr[200]; // change accordingly. the more items you have in your array the longer this str should be, you can eventually count how long you need this one to be
  33.         new tmpstr[64];
  34.        
  35.         for(new l = 0; l < sizeof listitems; l++)
  36.         {
  37.             format(tmpstr, sizeof tmpstr, "Name: %s\t\tCosts: %d\n", listitems[l][skinName], listitems[l][skinPrice]);
  38.             strcat(fullstr, tmpstr);
  39.         }
  40.         ShowPlayerDialog(playerid, DIALOG_ID_SKIN_SELECTION, DIALOG_STYLE_LIST, "Riided", fullstr, "I like!", "Cancel");
  41.         return 1;
  42.     }
  43.     return 0;
  44. }
  45.  
  46. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  47. {
  48.     new str[128];
  49.    
  50.     if(dialogid == DIALOG_ID_SKIN_SELECTION)
  51.     {
  52.         if(response)
  53.         {
  54.             SafeGivePlayerMoney(playerid, -listitems[listitem][skinPrice]);
  55.             GivePlayerWeapon(playerid, listitems[listitem][skinWeapon], listitems[listitem][skinAmmo]);
  56.             SetPlayerSkin(playerid, listitems[listitem][skinID]);
  57.  
  58.             format(str, sizeof str, "Item costed: $%d", listitems[listitem][skinPrice]);
  59.             SendClientMessage(playerid, COLOR_WHITE, str);
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment