Advertisement
FoxHound

RC-Zero Shop

Mar 8th, 2011
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.93 KB | None | 0 0
  1. /*
  2.  *                      RC Shop
  3.  *       (c) Copyright 2011-2012 by FoxHound
  4.  *
  5.  * @author    : FoxHound aka PSPgamer_10
  6.  * @date      : 12 February 2011
  7.  * @version   : v1.0
  8.  *
  9.  * This file is provided as is (no warranties).
  10.  *
  11.  *  _____         _   _                        _
  12.  * |  ___|       | | | |                      | |
  13.  * | |_ _____  __| |_| | ___  _   _  _ __   __| |
  14.  * |  _/ _ \ \/ /|  _  |/ _ \| | | || '_ \ / _` |
  15.  * | || (_) >  < | | | | (_) | |_| || | | ||(_| |
  16.  * \_| \___/_/\_\\_| |_/\___/ \__,_||_| |_|\__,_|
  17.  *
  18.  *          +--+-+-+-+-+-+-+-+-+-+--+
  19.  *          | p r o d u c t i o n s |
  20.  *          +--+-+-+-+-+-+-+-+-+-+--+
  21.  *
  22.  */
  23.  
  24. #include <a_samp>
  25. #include <dini>
  26.  
  27. #define RcBuyDialog 1487
  28.  
  29. #define ENABLE_RC_BUYING            //Enable the RC-Vehicles Buying System (Comment if you dont want to use this)
  30. #define ENABLE_BUYING_RCBARON       //Comment this if the Players shouldn't buy RcBaron (Note that RC Baron has a Gun, wich can kill the other Players in max. 3 seconds)
  31. #define ENABLE_RCZERO_ENTEREXIT     //Comment this, if you have already the enter-exit's for RC-Zero in one of your scripts
  32.  
  33. #define  RcBandit  441
  34. #define  RcRaider  465
  35. #define  RcGoblin  501
  36. #define  RcTiger   564
  37. #define  RcCam     594
  38. #define  RcBaron   464
  39.  
  40. #define  RcBanditCost   50000
  41. #define  RcRaiderCost   80000
  42. #define  RcGoblinCost   80000
  43. #define  RcTigerCost    60000
  44. #define  RcCamCost      30000
  45. #define  RcBaronCost    1000000
  46.  
  47. //RC-Shop Coordinates
  48. #define RcShopPosX -2236.9709
  49. #define RcShopPosY 130.1798
  50. #define RcShopPosZ 1035.4141
  51.  
  52. enum enum_pData
  53. {
  54.     pName[MAX_PLAYER_NAME],
  55.     pRcFile[MAX_PLAYER_NAME+3],
  56.     pRcVehID,
  57.     Float:posX,Float:posY,Float:posZ
  58. };
  59. enum enum_rcShopData
  60. {
  61.     rcTimer,
  62.     rcPickup,
  63.     rcZeroIn,
  64.     rcZeroOut
  65. };
  66. new pData[MAX_PLAYERS][enum_pData],
  67.     rcData[enum_rcShopData];
  68.  
  69. public OnFilterScriptInit()
  70. {
  71.     print("!* RC-Zero Shop");
  72.     print("!* by FoxHound");
  73.     print("!* successfully loaded !");
  74.  
  75.     #if defined ENABLE_RC_BUYING
  76.         rcData[rcPickup] = AddStaticPickup(2469, 23, RcShopPosX, RcShopPosY, RcShopPosZ, -1); //Rc-Buy Pos
  77.     #endif
  78.     #if defined ENABLE_RCZERO_ENTEREXIT
  79.     rcData[rcZeroIn] = AddStaticPickup(1559, 23, -2241.8171,128.6236,35.3203,-1); //RC-Zero In
  80.     rcData[rcZeroOut] = AddStaticPickup(1559, 23, -2240.7825,137.1801,1035.4141,-1); //RC-Zero Out
  81.     #endif
  82.  
  83.     rcData[rcTimer] = SetTimer("PlayerPosCheck",1000,1);
  84.     return 1;
  85. }
  86.  
  87. public OnFilterScriptExit()
  88. {
  89.     KillTimer(rcData[rcTimer]);
  90.     DestroyPickup(rcData[rcPickup]);
  91.     DestroyPickup(rcData[rcZeroIn]);
  92.     DestroyPickup(rcData[rcZeroOut]);
  93.     return 1;
  94. }
  95.  
  96. public OnPlayerConnect(playerid)
  97. {
  98.     #if defined ENABLE_RC_BUYING
  99.         GetPlayerName(playerid,pData[playerid][pName],MAX_PLAYER_NAME);
  100.         format(pData[playerid][pRcFile],MAX_PLAYER_NAME+3,"%s.rc",pData[playerid][pName]);
  101.     #endif
  102.     return 1;
  103. }
  104.  
  105. public OnPlayerDisconnect(playerid, reason)
  106. {
  107.     #if defined ENABLE_RC_BUYING
  108.         if(pData[playerid][pRcVehID] != 0)
  109.         {
  110.             DestroyVehicle(pData[playerid][pRcVehID]);
  111.             pData[playerid][pRcVehID] = 0;
  112.         }
  113.     #endif
  114.     return 1;
  115. }
  116.  
  117. public OnPlayerCommandText(playerid, cmdtext[])
  118. {
  119.     #if defined ENABLE_RC_BUYING
  120.         new mainstring[256];
  121.         if(!strcmp(cmdtext,"/buyrc",true))
  122.         {
  123.             if(!IsPlayerInRangeOfPoint(playerid,3.0,RcShopPosX,RcShopPosY,RcShopPosZ)) { return SendClientMessage(playerid,0xFAFAFAFF,"You are not in the RC-Zero Shop !"); }
  124.             if(dini_Exists(pData[playerid][pRcFile])) { return SendClientMessage(playerid,0xFF6347FF,"You already have a RC-Vehicle! Please sell it with /sellrc first!"); }
  125.             format(mainstring,sizeof(mainstring),"RC-Bandit (Mini-Car)    $%d\nRC-Raider (Mini-Heli)     $%d\nRC-Goblin (Mini-Heli)    $%d     (in Red)\nRC-Tiger (Mini-Rhino)     $%d\nRC-Cam (Flower pot)      $%d",RcBanditCost,RcRaiderCost,RcGoblinCost,RcTigerCost,RcCamCost);
  126.             #if defined ENABLE_BUYING_RCBARON
  127.                 new substring[64];
  128.                 format(substring,sizeof(substring),"\nRC-Baron (Mini-Dodo)     $%d     (+Integrated Gun)",RcBaronCost);
  129.                 strins(mainstring,substring,strlen(mainstring));
  130.             #endif
  131.             ShowPlayerDialog(playerid,RcBuyDialog,DIALOG_STYLE_LIST,"RC-Shop",mainstring,"Buy","Cancel");
  132.             return 1;
  133.         }
  134.         if(!strcmp(cmdtext,"/sellrc",true))
  135.         {
  136.             new string[128],sellcost;
  137.             if(!IsPlayerInRangeOfPoint(playerid,3.0,RcShopPosX,RcShopPosY,RcShopPosZ)) { return SendClientMessage(playerid,0xFAFAFAFF,"You are not in the RC-Zero Shop !"); }
  138.             if(!dini_Exists(pData[playerid][pRcFile])) { return SendClientMessage(playerid,0xFAFAFAFF,"You haven't a RC Vehicle to sell !"); }
  139.             switch(dini_Int(pData[playerid][pRcFile],"rcModel"))
  140.             {
  141.                 case RcBandit: {
  142.                     sellcost = RcBanditCost/3;
  143.                     format(string, sizeof(string), "You sold your RC Bandit for $%d !", sellcost); }
  144.                 case RcRaider: {
  145.                     sellcost = RcRaiderCost/3;
  146.                     format(string, sizeof(string), "You sold your RC Raider for $%d !", sellcost); }
  147.                 case RcGoblin: {
  148.                     sellcost = RcGoblinCost/3;
  149.                     format(string, sizeof(string), "You sold your RC Goblin for $%d !", sellcost); }
  150.                 case RcTiger: {
  151.                     sellcost = RcTigerCost/3;
  152.                     format(string, sizeof(string), "You sold your RC Tiger for $%d !", sellcost); }
  153.                 case RcCam: {
  154.                     sellcost = RcCamCost/3;
  155.                     format(string, sizeof(string), "You sold your RC Cam for $%d !", sellcost); }
  156.                 case RcBaron: {
  157.                     sellcost = RcBaronCost/3;
  158.                     format(string, sizeof(string), "You sold your RC Baron for $%d !", sellcost); }
  159.             }
  160.             SendClientMessage(playerid, 0xFFFFFFFF, string);
  161.             dini_Remove(pData[playerid][pRcFile]);
  162.             GivePlayerMoney(playerid, sellcost);
  163.             return 1;
  164.         }
  165.         if(!strcmp(cmdtext,"/userc",true))
  166.         {
  167.             new Float:pPos[4];
  168.             if(!dini_Exists(pData[playerid][pRcFile])) { return SendClientMessage(playerid,0xFAFAFAFF,"You haven't got a RC Vehicle! You can buy one in the RC-Zero Shop."); }
  169.             if(GetPlayerWantedLevel(playerid) > 0) { return SendClientMessage(playerid,0xFAFAFAFF,"You can't use your RC Vehicle because you have Wantedlevels!"); }
  170.             if(pData[playerid][pRcVehID]!=0) { return 1; }
  171.             GetPlayerPos(playerid,pPos[0],pPos[1],pPos[2]);
  172.             GetPlayerFacingAngle(playerid,pPos[3]);
  173.             pData[playerid][pRcVehID] = AddStaticVehicle(dini_Int(pData[playerid][pRcFile],"rcModel"),pPos[0],pPos[1],pPos[2],pPos[3],3,1);
  174.             PutPlayerInVehicle(playerid,pData[playerid][pRcVehID],0);
  175.             SendClientMessage(playerid,0x33CCFF00,"Type /exitrc to exit the RC Vehicle !");
  176.             return 1;
  177.         }
  178.         if(!strcmp(cmdtext,"/exitrc",true))
  179.         {
  180.             if(pData[playerid][pRcVehID]==0) { return 1; }
  181.             RemovePlayerFromVehicle(playerid);
  182.             DestroyVehicle(pData[playerid][pRcVehID]);
  183.             SetCameraBehindPlayer(playerid);
  184.             pData[playerid][pRcVehID]=0;
  185.             return 1;
  186.         }
  187.     #endif
  188.     return 0;
  189. }
  190.  
  191. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  192. {
  193.     if(dialogid == RcBuyDialog)
  194.     {
  195.         new string[128];
  196.         switch(response)
  197.         {
  198.             case 0: { return 1; }
  199.             case 1:
  200.             {
  201.                 if(!dini_Exists(pData[playerid][pRcFile])) { dini_Create(pData[playerid][pRcFile]); }
  202.                 switch(listitem)
  203.                 {
  204.                     case 0:
  205.                     {
  206.                         GivePlayerMoney(playerid,-RcBanditCost);
  207.                         dini_IntSet(pData[playerid][pRcFile],"rcModel",RcBandit);
  208.                         format(string,sizeof(string),"You bought a RC-Bandit for $%d !",RcBanditCost);
  209.                         SendClientMessage(playerid,0x33AA33AA,string);
  210.                         SendClientMessage(playerid,0x33AA33AA,"You can use it everytime when you haven't any Wanteds !");
  211.                     }
  212.                     case 1:
  213.                     {
  214.                         GivePlayerMoney(playerid,-RcRaiderCost);
  215.                         dini_IntSet(pData[playerid][pRcFile],"rcModel",RcRaider);
  216.                         format(string,sizeof(string),"You bought a RC-Raider for $%d !",RcRaiderCost);
  217.                         SendClientMessage(playerid,0x33AA33AA,string);
  218.                         SendClientMessage(playerid,0x33AA33AA,"You can use it everytime when you haven't any Wanteds !");
  219.                     }
  220.                     case 2:
  221.                     {
  222.                         GivePlayerMoney(playerid,-RcGoblinCost);
  223.                         dini_IntSet(pData[playerid][pRcFile],"rcModel",RcGoblin);
  224.                         format(string,sizeof(string),"You bought a RC-Goblin for $%d !",RcGoblinCost);
  225.                         SendClientMessage(playerid,0x33AA33AA,string);
  226.                         SendClientMessage(playerid,0x33AA33AA,"You can use it everytime when you haven't any Wanteds !");
  227.                     }
  228.                     case 3:
  229.                     {
  230.                         GivePlayerMoney(playerid,-RcTigerCost);
  231.                         dini_IntSet(pData[playerid][pRcFile],"rcModel",RcTiger);
  232.                         format(string,sizeof(string),"You bought a RC-Tiger for $%d !",RcTigerCost);
  233.                         SendClientMessage(playerid,0x33AA33AA,string);
  234.                         SendClientMessage(playerid,0x33AA33AA,"You can use it everytime when you haven't any Wanteds !");
  235.                     }
  236.                     case 4:
  237.                     {
  238.                         GivePlayerMoney(playerid,-RcCamCost);
  239.                         dini_IntSet(pData[playerid][pRcFile],"rcModel",RcCam);
  240.                         format(string,sizeof(string),"You bought a RC-Cam for $%d !",RcCamCost);
  241.                         SendClientMessage(playerid,0x33AA33AA,string);
  242.                         SendClientMessage(playerid,0x33AA33AA,"You can use it everytime when you haven't any Wanteds !");
  243.                     }
  244.                     case 5:
  245.                     {
  246.                         GivePlayerMoney(playerid,-RcBaronCost);
  247.                         dini_IntSet(pData[playerid][pRcFile],"rcModel",RcBaron);
  248.                         format(string,sizeof(string),"You bought a RC-Baron for $%d !",RcBaronCost);
  249.                         SendClientMessage(playerid,0x33AA33AA,string);
  250.                         SendClientMessage(playerid,0x33AA33AA,"You can use it everytime when you haven't any Wanteds !");
  251.                         SendClientMessage(playerid,0x33AA33AA,"But be careful! RC-Baron can kill Players with the Gun !");
  252.                     }
  253.                 }
  254.             }
  255.         }
  256.     }
  257.     return 1;
  258. }
  259.  
  260. forward PlayerPosCheck();
  261. public PlayerPosCheck()
  262. {
  263.     new i;
  264.     for(; i<GetMaxPlayers(); i++)
  265.     {
  266.         if(IsPlayerConnected(i))
  267.         {
  268.             if(IsPlayerInRangeOfPoint(i,3.0,RcShopPosX,RcShopPosY,RcShopPosZ))
  269.             {
  270.                 if(dini_Int(pData[i][pRcFile],"rcModel") <= 0)
  271.                 {
  272.                     #if defined ENABLE_RC_BUYING
  273.                         GameTextForPlayer(i,"~r~RC-Zero~n~~w~Type ~b~/buyrc ~w~to~n~~y~buy ~w~a RC Vehicle",1000,1);
  274.                     #endif
  275.                 }
  276.                 else
  277.                 {
  278.                     GameTextForPlayer(i,"~r~RC-Zero~n~~w~Type ~b~/sellrc ~w~to~n~~y~sell ~w~your RC Vehicle",1000,1);
  279.                 }
  280.             }
  281.             #if defined ENABLE_RCZERO_ENTEREXIT
  282.                 if(IsPlayerInRangeOfPoint(i,1.0,-2241.8171,128.6236,35.3203))
  283.                 {//RC-Zero In
  284.                     GameTextForPlayer(i, "~y~RC~b~-Zero", 1000, 3);
  285.                     SetPlayerPos(i, -2238.4312,136.8570,1035.4141);
  286.                     SetPlayerFacingAngle(i,240.0);
  287.                     SetCameraBehindPlayer(i);
  288.                     SetPlayerInterior(i,6);
  289.                     SetPlayerVirtualWorld(i, 0);
  290.                 }
  291.                 else if(IsPlayerInRangeOfPoint(i,1.0,-2240.7825,137.1801,1035.4141))
  292.                 {//RC-Zero Out
  293.                     GameTextForPlayer(i, "~b~San Fierro", 1000, 3);
  294.                     SetPlayerPos(i, -2243.8650,128.6740,35.3203);
  295.                     SetPlayerFacingAngle(i,90.0);
  296.                     SetCameraBehindPlayer(i);
  297.                     SetPlayerInterior(i,0);
  298.                     SetPlayerVirtualWorld(i, 0);
  299.                 }
  300.             #endif
  301.         }
  302.     }
  303.     return 1;
  304. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement