Guest User

Colocar Player no Portamalas By: XxASxX

a guest
Jan 23rd, 2017
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.16 KB | None | 0 0
  1. /*
  2. FS de colocar o player no porta-malas
  3. Não retire os creditos.
  4. By: XxASxX YBanY
  5. */
  6.  
  7. #include <a_samp>
  8. #include <zcmd>
  9. #include <sscanf2>
  10. #include <foreach>
  11.  
  12. #undef MAX_PLAYERS
  13. #define MAX_PLAYERS (100)
  14. #define SendServerMessage(%0,%1) \
  15. SendClientMessageEx(%0, COLOR_SERVER, "{FFFFFF}SERVIDOR: "%1)
  16. #define SendErrorMessage(%0,%1) \
  17. SendClientMessageEx(%0, COLOR_LIGHTRED, "[ERRO]:{FFFFFF} "%1)
  18. #define SendSyntaxMessage(%0,%1) \
  19. SendClientMessageEx(%0, COLOR_GREY, "[SYNTAX]:{FFFFFF} "%1) // COLOR_YELLOW
  20.  
  21. #define COLOR_PURPLE (0xD0AEEBFF)
  22. #define COLOR_SERVER (0xFFFF90FF)
  23. #define COLOR_LIGHTRED (0xFF6347FF)
  24. #define COLOR_GREY (0xAFAFAFFF)
  25. #define COLOR_RED (0xFF0000FF)
  26. new Tanoportamalas[MAX_PLAYERS];
  27. new
  28. pWorld[MAX_PLAYERS],
  29. pInterior[MAX_PLAYERS],
  30. pSpectator[MAX_PLAYERS],
  31. Float:pPos[4];
  32. #if defined FILTERSCRIPT
  33.  
  34. public OnFilterScriptInit()
  35. {
  36. print("\n--------------------------------------");
  37. print(" PlayerMala carregado |By: XxASxX|");
  38. print("--------------------------------------\n");
  39. return 1;
  40. }
  41.  
  42. public OnFilterScriptExit()
  43. {
  44. return 1;
  45. }
  46.  
  47. #else
  48.  
  49. main()
  50. {
  51. print("\n----------------------------------");
  52. print(" PlayerMala descarregado |By: XxASxX|");
  53. print("----------------------------------\n");
  54. }
  55.  
  56. #endif
  57.  
  58. public OnGameModeInit()
  59. {
  60. return 1;
  61. }
  62.  
  63. public OnGameModeExit()
  64. {
  65. return 1;
  66. }
  67.  
  68.  
  69. public OnPlayerConnect(playerid)
  70. {
  71. Tanoportamalas[playerid] = 0;
  72. return 1;
  73. }
  74.  
  75. public OnPlayerDisconnect(playerid, reason)
  76. {
  77. return 1;
  78. }
  79.  
  80. public OnPlayerSpawn(playerid)
  81. {
  82. return 1;
  83. }
  84.  
  85. public OnPlayerDeath(playerid, killerid, reason)
  86. {
  87. return 1;
  88. }
  89.  
  90. public OnVehicleSpawn(vehicleid)
  91. {
  92. return 1;
  93. }
  94.  
  95. public OnVehicleDeath(vehicleid, killerid)
  96. {
  97. return 1;
  98. }
  99.  
  100. public OnPlayerText(playerid, text[])
  101. {
  102. if (Tanoportamalas[playerid] == 1)
  103. {
  104. SendNearbyMessage(playerid, 35.0, COLOR_RED, "[Porta Malas]: {FFFFFF}%s diz: %s", ReturnName(playerid, 0), text);
  105. return 1;
  106. }
  107. return 1;
  108. }
  109.  
  110. public OnPlayerCommandText(playerid, cmdtext[])
  111. {
  112. return 0;
  113. }
  114. CMD:colocarnopmalas(playerid, params[])
  115. {
  116. static
  117. userid;
  118. new vehicleid = GetPlayerVehicleID(playerid);
  119. if (sscanf(params, "ud", userid))
  120. return SendSyntaxMessage(playerid, "/colocarnopmalas [playerid/nome]");
  121.  
  122. if (userid == INVALID_PLAYER_ID || !IsPlayerNearPlayer(playerid, userid, 5.0))
  123. return SendErrorMessage(playerid, "O jogador não esta perto de voce.");
  124.  
  125. if(!IsPlayerInAnyVehicle(userid)) return SendErrorMessage(playerid, "O jogador precisa está dentro do veículo (Para não bugar).");
  126. SetPlayerPos(userid, 2264.8218, -1213.3932, 1048.9272);
  127. SetPlayerInterior(userid, 1);
  128. Tanoportamalas[userid] = 1;
  129. SetPlayerVirtualWorld(userid, (playerid + 100));
  130. SetPlayerFacingAngle(userid, 0.0);
  131.  
  132.  
  133. if (GetPlayerState(userid) != PLAYER_STATE_SPECTATING)
  134. {
  135. GetPlayerPos(userid, pPos[0], pPos[1], pPos[2]);
  136. GetPlayerFacingAngle(userid, pPos[3]);
  137.  
  138. pInterior[userid] = GetPlayerInterior(userid);
  139. pWorld[userid] = GetPlayerVirtualWorld(userid);
  140. }
  141. SetPlayerInterior(userid, GetPlayerInterior(vehicleid));
  142. SetPlayerVirtualWorld(userid, GetPlayerVirtualWorld(vehicleid));
  143. TogglePlayerSpectating(userid, 1);
  144. if (IsPlayerInAnyVehicle(playerid))
  145. PlayerSpectateVehicle(userid, GetPlayerVehicleID(playerid));
  146. else
  147. PlayerSpectatePlayer(userid, vehicleid);
  148. pSpectator[userid] = vehicleid;
  149.  
  150. ApplyAnimationEx(userid, "BEACH", "ParkSit_M_loop", 4.1, 1, 0, 0, 0, 0, 1);
  151.  
  152. SendServerMessage(userid, "Você está dentro do porta-malas.");
  153. SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s colocou %s no porta malas.", ReturnName(playerid, 0), ReturnName(userid, 0));
  154. return 1;
  155. }
  156. CMD:retirardopmalas(playerid, params[])
  157. {
  158. static
  159. userid;
  160. if (sscanf(params, "u", userid))
  161. return SendSyntaxMessage(playerid, "/retirardopmalas [playerid/nome]");
  162. if(!IsPlayerInAnyVehicle(playerid))
  163. return SendErrorMessage(playerid, "Você precisa está dentro do veículo (Para não bugar).");
  164. if (userid == INVALID_PLAYER_ID)
  165. return SendErrorMessage(playerid, "Você especificou um jogador inválido.");
  166.  
  167. new Float:X, Float:Y, Float:Z;
  168. if (Tanoportamalas[userid] == 1)
  169. {
  170. TogglePlayerSpectating(userid, false);
  171. Tanoportamalas[userid] = 0;
  172. pWorld[userid] = playerid;
  173. GetPlayerPos(playerid, X, Y, Z);
  174. SetPlayerPos(strval(params), X, Y, Z+1);
  175. SetPlayerVirtualWorld(userid, GetPlayerVirtualWorld(playerid));
  176. SendNearbyMessage(playerid, 30.0, COLOR_PURPLE, "** %s retirou %s do porta malas.", ReturnName(playerid, 0), ReturnName(userid, 0));
  177. }
  178. else SendErrorMessage(playerid, "Este player não está no porta-malas");
  179. return 1;
  180. }
  181. stock SendClientMessageEx(playerid, color, const text[], {Float, _}:...)
  182. {
  183. static
  184. args,
  185. str[144];
  186.  
  187. /*
  188. * Custom function that uses #emit to format variables into a string.
  189. * This code is very fragile; touching any code here will cause crashing!
  190. */
  191. if ((args = numargs()) == 3)
  192. {
  193. SendClientMessage(playerid, color, text);
  194. }
  195. else
  196. {
  197. while (--args >= 3)
  198. {
  199. #emit LCTRL 5
  200. #emit LOAD.alt args
  201. #emit SHL.C.alt 2
  202. #emit ADD.C 12
  203. #emit ADD
  204. #emit LOAD.I
  205. #emit PUSH.pri
  206. }
  207. #emit PUSH.S text
  208. #emit PUSH.C 144
  209. #emit PUSH.C str
  210. #emit PUSH.S 8
  211. #emit SYSREQ.C format
  212. #emit LCTRL 5
  213. #emit SCTRL 4
  214.  
  215. SendClientMessage(playerid, color, str);
  216.  
  217. #emit RETN
  218. }
  219. return 1;
  220. }
  221. stock IsPlayerNearPlayer(playerid, targetid, Float:radius)
  222. {
  223. static
  224. Float:fX,
  225. Float:fY,
  226. Float:fZ;
  227.  
  228. GetPlayerPos(targetid, fX, fY, fZ);
  229.  
  230. return (GetPlayerInterior(playerid) == GetPlayerInterior(targetid) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(targetid)) && IsPlayerInRangeOfPoint(playerid, radius, fX, fY, fZ);
  231. }
  232. stock ApplyAnimationEx(playerid, animlib[], animname[], Float:fDelta, loop, lockx, locky, freeze, time, forcesync = 0)
  233. {
  234. ApplyAnimation(playerid, animlib, animname, fDelta, loop, lockx, locky, freeze, time, forcesync);
  235. return 1;
  236. }
  237. stock SendNearbyMessage(playerid, Float:radius, color, const str[], {Float,_}:...)
  238. {
  239. static
  240. args,
  241. start,
  242. end,
  243. string[144]
  244. ;
  245. #emit LOAD.S.pri 8
  246. #emit STOR.pri args
  247.  
  248. if (args > 16)
  249. {
  250. #emit ADDR.pri str
  251. #emit STOR.pri start
  252.  
  253. for (end = start + (args - 16); end > start; end -= 4)
  254. {
  255. #emit LREF.pri end
  256. #emit PUSH.pri
  257. }
  258. #emit PUSH.S str
  259. #emit PUSH.C 144
  260. #emit PUSH.C string
  261.  
  262. #emit LOAD.S.pri 8
  263. #emit CONST.alt 4
  264. #emit SUB
  265. #emit PUSH.pri
  266.  
  267. #emit SYSREQ.C format
  268. #emit LCTRL 5
  269. #emit SCTRL 4
  270.  
  271. foreach (new i : Player)
  272. {
  273. if (IsPlayerNearPlayer(i, playerid, radius)) {
  274. SendClientMessage(i, color, string);
  275. }
  276. }
  277. return 1;
  278. }
  279. foreach (new i : Player)
  280. {
  281. if (IsPlayerNearPlayer(i, playerid, radius)) {
  282. SendClientMessage(i, color, str);
  283. }
  284. }
  285. return 1;
  286. }
  287. ReturnName(playerid, underscore=1)
  288. {
  289. static
  290. name[MAX_PLAYER_NAME + 1];
  291.  
  292. GetPlayerName(playerid, name, sizeof(name));
  293.  
  294. if (!underscore) {
  295. for (new i = 0, len = strlen(name); i < len; i ++) {
  296. if (name[i] == '_') name[i] = ' ';
  297. }
  298. }
  299. return name;
  300. }
Advertisement
Add Comment
Please, Sign In to add comment