Guest User

Store Filter Script

a guest
May 23rd, 2014
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.68 KB | None | 0 0
  1. /*                Filter Script made by Fred
  2.                 Do not remove this
  3.                 For any help pm me on forum.sa-mp.com, my name is Fred1993
  4. */
  5.  
  6. #include <a_samp>
  7.  
  8.  
  9. public OnFilterScriptInit() // This is where filter script starts
  10. {
  11.     print("\n--------------------------------------");
  12.     print(" Store Filterscript by Fred");
  13.     print("--------------------------------------\n");
  14.     return 1;
  15. }
  16.  
  17. public OnFilterScriptExit()
  18. {
  19.     return 1;
  20. }
  21.  
  22. enum StoreInfo {  // enums used for the stores
  23.     Sid,
  24.     Sname[256],
  25.     Smoney,
  26. };
  27. new Stores[][StoreInfo] = { // variables using enums(Sid, Sname, Smoney)
  28. {30 ,"AK-47"    ,3000},
  29. {31 ,"M4"   , 4000},
  30. {24 ,"Deagle"   , 2000}
  31. };
  32.  
  33. public OnPlayerCommandText(playerid, cmdtext[])
  34. {
  35.     if(strcmp("/store", cmdtext, true, 10) == 0)
  36.     {
  37.         new tmsg[2500];
  38.         new msg[256];
  39.         for(new i=0;i<sizeof(Stores);i++) // for loop
  40.         {
  41.             format(msg,sizeof(msg),"%s - $%d\n",Stores[i][Sname],Stores[i][Smoney]); // Storing String of gun name and gun money in "msg"
  42.             strcat(tmsg,msg,sizeof(tmsg)); // conatinating tmsg and msg
  43.         }
  44.         ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Store Menu",tmsg,"Buy", "Cancel");
  45.         return 1;
  46.     }
  47.     return 0;
  48. }
  49.  
  50. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) // this is where dialog box response
  51. {
  52.     if(dialogid == 1) // 1 is the dialogbox id
  53.     {
  54.         if(response)
  55.         {
  56.             if(listitem >= 0 && listitem <sizeof(Stores))
  57.             {
  58.                 GivePlayerWeapon(playerid, Stores[listitem][Sid], 400);
  59.                 GivePlayerMoney(playerid, -(Stores[listitem][Smoney]));
  60.                 SendClientMessage(playerid, -1, "Successfully Bought"); // -1 is white color..
  61.             }
  62.         }
  63.         return 1;
  64.     }
  65.     return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment