Guest User

Advance Robbing System Creater InGame.

a guest
Jun 15th, 2016
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.03 KB | None | 0 0
  1. //==============================includes ======================================//
  2. #include <a_samp>
  3. #include <foreach>
  4. #include <zcmd>
  5. #include <sscanf2>
  6. #include <YSI\y_ini>
  7. #include <streamer>
  8. //================================Define ======================================//
  9. #define SCM SendClientMessage
  10. #define SCMToAll SendClientMessageToAll
  11. #define MAX_ROBABLE_SHOPS 100
  12. //================================Color ======================================//
  13. #define COLOR_YELLOW 0xFFFF00AA
  14. #define COLOR_GREEN 0x33AA33AA
  15. //==============================Varaibles=====================================//
  16. new CP[MAX_ROBABLE_SHOPS];
  17. new IsPlaceRobbedAlready[MAX_ROBABLE_SHOPS];
  18. new Captured[MAX_PLAYERS][MAX_ROBABLE_SHOPS];
  19. new PlayerWasInShop[MAX_PLAYERS][MAX_ROBABLE_SHOPS];
  20. new TIMER[MAX_PLAYERS][MAX_ROBABLE_SHOPS];
  21. new RobbingTimer[MAX_PLAYERS];
  22. new CountDown[MAX_PLAYERS];
  23. new RandomCash[] = {1000,700,1200,1300,500};
  24. new RobPlaceAvailableTimer[MAX_ROBABLE_SHOPS];
  25. new Rstr[128];
  26. new ID;
  27. new ShopActor[MAX_ROBABLE_SHOPS];
  28.  
  29. enum Shops
  30. {
  31. Float:ShopX,
  32. Float:ShopY,
  33. Float:ShopZ,
  34. Float:ShopA,
  35. ShopInt,
  36. ShopVw,
  37. ShopName[30]
  38. };
  39. new sInfo[MAX_ROBABLE_SHOPS][Shops];
  40.  
  41. //CreateDynamicCP(Float:x, Float:y, Float:z, Float:size, worldid = -1, interiorid = -1, playerid = -1,Float:distance = 100.0);
  42.  
  43. #if defined FILTERSCRIPT
  44.  
  45. public OnFilterScriptInit()
  46. {
  47. for(new i = 0 ; i < MAX_ROBABLE_SHOPS; i++)
  48. {
  49. new gFile[35];
  50. format(gFile, 35, "RobSystem/%d.ini" ,i);
  51. if(fexist(gFile))
  52. {
  53. INI_ParseFile(gFile, "LoadShops", .bExtra = true, .extra = i);
  54. CP[i] = CreateDynamicCP(sInfo[i][ShopX],sInfo[i][ShopY],sInfo[i][ShopZ], 3.0, -1, sInfo[i][ShopInt], -1, 100.0);
  55. ShopActor[i] = CreateActor(275,sInfo[i][ShopX],sInfo[i][ShopY],sInfo[i][ShopZ],sInfo[i][ShopA]+180);
  56. }
  57. }
  58. print("\n--------------------------------------");
  59. print(" FILTERSCRIPT ROB SYSTEM LOADED ");
  60. print(" CREATED BY MUHAMMAD BILAL ");
  61. print("--------------------------------------\n");
  62. return 1;
  63. }
  64.  
  65. public OnFilterScriptExit()
  66. {
  67. for(new i = 0 ; i < MAX_ROBABLE_SHOPS; i++)
  68. {
  69. IsPlaceRobbedAlready[i] = 0 ;
  70. DestroyActor(ShopActor[i]);
  71. }
  72. print("\n--------------------------------------");
  73. print(" FILTERSCRIPT ROB SYSTEM UNLOADED ");
  74. print(" CREATED BY MUHAMMAD BILAL ");
  75. print("--------------------------------------\n");
  76. return 1;
  77. }
  78.  
  79. #else
  80.  
  81. main()
  82. {
  83. print("\n----------------------------------");
  84. print(" FILTERSCRIPT RACE SYSTEM LOADED ");
  85. print(" CREATED BY MUHAMMAD BILAL ");
  86. print("----------------------------------\n");
  87. }
  88.  
  89. #endif
  90.  
  91. GetName(playerid)
  92. {
  93. new Name[MAX_PLAYER_NAME];
  94. GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
  95. return Name;
  96. }
  97.  
  98. forward OnPlayerEnterDynamicCP(playerid, checkpointid);
  99. public OnPlayerEnterDynamicCP(playerid, checkpointid)
  100. {
  101. for (new i = 0; i < MAX_ROBABLE_SHOPS ; i++ )
  102. {
  103. if(checkpointid == CP[i])
  104. {
  105. if(GetPlayerState(playerid) != 9)
  106. {
  107. if(GetPlayerWeapon(playerid) != 0)
  108. {
  109. if(IsPlaceRobbedAlready[i] != 1)
  110. {
  111. CheckPlayerShop(playerid,i);
  112. break;
  113. }
  114. else
  115. {
  116. GameTextForPlayer( playerid, "~r~This shop is not available~n~to Rob at this moment", 3000, 5 );
  117. break;
  118. }
  119. }
  120. else
  121. {
  122. GameTextForPlayer( playerid, "~r~You're not allowed to rob~n~You have no weapon to aim at ~n~security guard.", 3000, 5 );//here i'm sending message if that player is robbed already than show him that message only.
  123. break;
  124. }
  125. }
  126. else
  127. {
  128. GameTextForPlayer( playerid, "~r~You're not allowed to rob when you're spectating.", 3000, 5 );
  129. break;
  130. }
  131. }
  132. }
  133. return 1;
  134. }
  135.  
  136. CheckPlayerShop(playerid,ShopID)
  137. {
  138. ApplyActorAnimation(ShopActor[ShopID], "ped","handsup",4.1,0,1,1,1,0);
  139. IsPlaceRobbedAlready[ShopID] = 1;
  140. ApplyAnimation(playerid, "SHOP", "ROB_Loop_Threat", 4.0, 1, 0, 0, 0, 0);
  141. PlayerWasInShop[playerid][ShopID] = 1;
  142. Captured[playerid][ShopID] = 0;
  143. CountDown[playerid] = 25;
  144. TIMER[playerid][ShopID] = SetTimerEx("OnPlayerStartRobbingShop",25000, false,"di",playerid,ShopID);
  145. RobbingTimer[playerid] = SetTimerEx("OnPlayerRobCountDown", 1000, true,"d",playerid);
  146. SCM(playerid,COLOR_YELLOW,"-|stay in this checkpoint for 25 seconds to rob this place.|-");
  147. return 1;
  148. }
  149.  
  150. forward OnPlayerRobCountDown(playerid);
  151. public OnPlayerRobCountDown(playerid)
  152. {
  153. for (new i = 0; i < MAX_ROBABLE_SHOPS ; i++ )
  154. {
  155. if(IsPlayerInDynamicCP(playerid, CP[i]) && IsPlaceRobbedAlready[i] == 1 && GetPlayerState(playerid) != 9 )
  156. {
  157. OnPlayerRobTimeLeft(playerid);
  158. break;
  159. }
  160. }
  161. return 1;
  162. }
  163.  
  164. OnPlayerRobTimeLeft(playerid)
  165. {
  166. switch(CountDown[playerid])
  167. {
  168. case 1..25:
  169. {
  170. format(Rstr, sizeof(Rstr),"~y~To Complete~n~~r~Robbing ~n~~y~Time Left ~n~~b~%d",CountDown[playerid]);
  171. GameTextForPlayer(playerid,Rstr,1000,3);
  172. PlayerPlaySound(playerid, 4203, 0.0, 0.0, 0.0);
  173. }
  174. }
  175. CountDown[playerid]--;
  176. return 1;
  177. }
  178.  
  179. forward OnPlayerStartRobbingShop(playerid,ShopID);
  180. public OnPlayerStartRobbingShop(playerid,ShopID)
  181. {
  182. ClearAnimations(playerid);
  183. ClearActorAnimations(ShopActor[ShopID]);
  184. KillTimer(TIMER[playerid][ShopID]);
  185. KillTimer(RobbingTimer[playerid]);
  186. Captured[playerid][ShopID] = 1;
  187. SetPlayerScore(playerid, GetPlayerScore(playerid) + 2);
  188. new Money = RandomCash[random(5)];
  189. GivePlayerMoney(playerid, Money);
  190. PlayerPlaySound(playerid,17802,0.0,0.0,0.0);
  191. format(Rstr,sizeof(Rstr),"-| %s has Robbed %d $ from %s |-",GetName(playerid),Money,sInfo[ShopID][ShopName]);
  192. SCMToAll(COLOR_GREEN,Rstr);
  193. IsPlaceRobbedAlready[ShopID] = 1;
  194. PlayerWasInShop[playerid][ShopID] = 0;
  195. RobPlaceAvailableTimer[ShopID] = SetTimerEx("PlaceAlreadyRobbed", 25*60*1000, 0 ,"i",ShopID);
  196. return 1;
  197. }
  198.  
  199. forward PlaceAlreadyRobbed(ShopID);
  200. public PlaceAlreadyRobbed(ShopID)
  201. {
  202. KillTimer(RobPlaceAvailableTimer[ShopID]);
  203. IsPlaceRobbedAlready[ShopID] = 0;
  204. }
  205.  
  206. forward OnPlayerLeaveDynamicCP(playerid, checkpointid);
  207. public OnPlayerLeaveDynamicCP(playerid, checkpointid)
  208. {
  209. for (new i = 0; i < MAX_ROBABLE_SHOPS ; i++ )
  210. {
  211. if(checkpointid == CP[i] && Captured[playerid][i] == 0 && !IsPlayerInDynamicCP(playerid, CP[i] && PlayerWasInShop[playerid][i] == 1))
  212. {
  213. FailToRob(playerid,i);
  214. break;
  215. }
  216. }
  217. }
  218.  
  219. FailToRob(playerid,ShopID)
  220. {
  221. ClearAnimations(playerid);
  222. ClearActorAnimations(ShopActor[ShopID]);
  223. KillTimer(RobbingTimer[playerid]);
  224. KillTimer(TIMER[playerid][ShopID]);
  225. Captured[playerid][ShopID] = 0;
  226. IsPlaceRobbedAlready[ShopID] = 0;
  227. PlayerWasInShop[playerid][ShopID] = 0;
  228. format(Rstr, sizeof(Rstr),"~r~You are failed to rob ~b~~n~%s", sInfo[ShopID][ShopName]);
  229. GameTextForPlayer( playerid, Rstr, 5000, 3 );
  230. return 1;
  231. }
  232.  
  233. OnPlayerLeaveShop(playerid)
  234. {
  235. for (new i = 0; i < MAX_ROBABLE_SHOPS ; i++ )
  236. {
  237. if(Captured[playerid][i] == 0 && PlayerWasInShop[playerid][i] == 1 && IsPlaceRobbedAlready[i] == 1)
  238. {
  239. FailToRob(playerid , i);
  240. break;
  241. }
  242. }
  243. return 1;
  244. }
  245.  
  246. public OnPlayerDisconnect(playerid,reason)
  247. {
  248. OnPlayerLeaveShop(playerid);
  249. return 1;
  250. }
  251.  
  252. public OnPlayerConnect(playerid)
  253. {
  254. OnPlayerLeaveShop(playerid);
  255. return 1;
  256. }
  257.  
  258. public OnPlayerSpawn(playerid)
  259. {
  260. OnPlayerLeaveShop(playerid);
  261. return 1;
  262. }
  263.  
  264. CMD:cancelrob(playerid)return OnPlayerLeaveShop(playerid);
  265.  
  266. CMD:crobcp(playerid,params[])
  267. {
  268. new string[30];
  269. if(!IsPlayerAdmin(playerid))return SCM(playerid,COLOR_GREEN,"[MB-RACE SYSTEM]: You need to be rcon admin to use this cmd.");
  270. if(sscanf(params,"s[30]",string))return SCM(playerid,COLOR_YELLOW,"/crobcp [Shop Name]");
  271. new Float:CpPos[4],Int,Vw,dFile[32];
  272. GetPlayerPos(playerid,CpPos[0],CpPos[1],CpPos[2]);
  273. GetPlayerFacingAngle(playerid,CpPos[3]);
  274. Int = GetPlayerInterior(playerid);
  275. Vw = GetPlayerVirtualWorld(playerid);
  276. format(dFile, 35, "RobSystem/%d.ini", ID);
  277. new INI:File = INI_Open(dFile);
  278. INI_SetTag(File,"Shop");
  279. INI_WriteFloat(File,"CpX",CpPos[0]);
  280. INI_WriteFloat(File,"CpY",CpPos[1]);
  281. INI_WriteFloat(File,"CpZ",CpPos[2]);
  282. INI_WriteFloat(File,"CpA",CpPos[3]);
  283. INI_WriteInt(File,"CpInt",Int);
  284. INI_WriteInt(File,"CpVw",Vw);
  285. INI_WriteInt(File,"CpID",ID);
  286. INI_WriteString(File,"CpName",string);
  287. INI_Close(File);
  288. SCM(playerid,COLOR_YELLOW,"You have successfully saved the position of the rob point.");
  289. CP[ID] = CreateDynamicCP(CpPos[0],CpPos[1],CpPos[2], 3.0, -1, Int, -1, 100.0);
  290. ShopActor[ID] = CreateActor(275,CpPos[0],CpPos[1],CpPos[2],CpPos[3]+180);
  291. SetPlayerPos(playerid,CpPos[0],CpPos[1]+2,CpPos[2]);
  292. sInfo[ID][ShopName] = string;
  293. ID++;
  294. return 1;
  295. }
  296.  
  297. forward LoadShops(id, name[], value[]);
  298. public LoadShops(id, name[], value[])
  299. {
  300. INI_Float("CpX", sInfo[id][ShopX]);
  301. INI_Float("CpY", sInfo[id][ShopY]);
  302. INI_Float("CpZ", sInfo[id][ShopZ]);
  303. INI_Float("CpA", sInfo[id][ShopA]);
  304. INI_Int("CpInt", sInfo[id][ShopInt]);
  305. INI_Int("CpVw", sInfo[id][ShopVw]);
  306. INI_Int("CpID", ID);
  307. INI_String("CpName",sInfo[id][ShopName],30);
  308. return 1;
  309. }
Add Comment
Please, Sign In to add comment