Guest User

Version 1.1 Advance Robbing System Creater InGame.

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