Badyx

Untitled

May 7th, 2013
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3.  
  4. enum pInfo
  5. {
  6. pEstrellas,
  7. pEnCarcel,
  8. pTiempo
  9. };
  10. new PlayerInfo[MAX_PLAYERS][pInfo];
  11.  
  12. new DetectarJail;
  13. #define Rojo 0xa80707FF
  14.  
  15. public OnFilterScriptInit()
  16. {
  17. DetectarJail = SetTimer("SacarDeLaCarcel", 1000, 1);
  18. return 1;
  19. }
  20.  
  21.  
  22. #if defined FILTERSCRIPT
  23.  
  24. #else
  25.  
  26. main(){}
  27.  
  28. #endif
  29.  
  30. public OnPlayerConnect(playerid)
  31. {
  32. if(PlayerInfo[playerid][pEstrellas] > 0) return MetenEnJail(playerid);
  33. return 1;
  34. }
  35.  
  36. public OnPlayerDisconnect(playerid, reason)
  37. {
  38. KillTimer(DetectarJail);
  39. return 1;
  40. }
  41.  
  42.  
  43.  
  44.  
  45. public OnPlayerCommandText(playerid, cmdtext[])
  46. {
  47. new cmd[256];
  48. new idx;
  49. cmd = strtok(cmdtext, idx);
  50. new tmp[256];
  51.  
  52. if(strcmp(cmd, "/Estrellas", true) == 0)
  53. {
  54. new IdIndicada;
  55. new Estrellas;
  56. new MaximoEstrellas;
  57. if(IsPlayerConnected(playerid))
  58. {
  59. tmp = strtok(cmdtext, idx);
  60. if(!strlen(tmp)) return SendClientMessage(playerid, Rojo, "[Uso:] /Estrellas [Id/Nombre] [Cantidad]");
  61. if(MaximoEstrellas < 0 || MaximoEstrellas > 6) return SendClientMessage(playerid, Rojo, "[Error] Minimo 0 maximo 6");
  62.  
  63.  
  64. IdIndicada = ReturnUser(tmp);
  65. tmp = strtok(cmdtext, idx);
  66. Estrellas = strval(tmp);
  67. if(IsPlayerConnected(IdIndicada))
  68. {
  69. if(IdIndicada != INVALID_PLAYER_ID)
  70. {
  71. SetPlayerWantedLevel(IdIndicada, Estrellas);
  72. PlayerInfo[IdIndicada][pEstrellas] = Estrellas;
  73. }
  74. }
  75. }
  76. return 1;
  77. }
  78. return 0;
  79. }
  80.  
  81. forward MetenEnJail(playerid);
  82. public MetenEnJail(playerid)
  83. {
  84.  
  85. new tmp[64];
  86. format(tmp, sizeof(tmp), "Desconectaste con un nivel de %d estrellas", PlayerInfo[playerid][pEstrellas]);
  87. SendClientMessage(playerid, 0xFF0000FF, tmp);
  88. ResetPlayerWeapons(playerid);
  89. PlayerInfo[playerid][pEnCarcel] = 1;
  90. SetPlayerInterior(playerid, 0);
  91. SetPlayerPos(playerid, 3058.5444,2999.5657,0.9986);
  92. new Tiempo = PlayerInfo[playerid][pEstrellas] *= 600000;
  93. PlayerInfo[playerid][pTiempo] = Tiempo ;
  94. return 1;
  95. }
  96.  
  97.  
  98. forward SacarDeLaCarcel();
  99. public SacarDeLaCarcel()
  100. {
  101. new string[10];
  102. for(new i = 0; i < MAX_PLAYERS; i++)
  103. {
  104. if(PlayerInfo[i][pEnCarcel] > 0)
  105. {
  106. if(PlayerInfo[i][pTiempo] > 0) return PlayerInfo[i][pTiempo]--;
  107. if(PlayerInfo[i][pTiempo] <= 0)
  108. {
  109. PlayerInfo[i][pTiempo] = 0;
  110. PlayerInfo[i][pEnCarcel] = 0;
  111. format(string, sizeof(string), "~g~Libre");
  112. }
  113. }
  114. }
  115. return 1;
  116. }
  117.  
  118.  
  119.  
  120. strtok(string[],&idx,seperator = ' ')
  121. {
  122. new ret[128], i = 0, len = strlen(string);
  123. while(string[idx] == seperator && idx < len) idx++;
  124. while(string[idx] != seperator && idx < len)
  125. {
  126. ret[i] = string[idx];
  127. i++;
  128. idx++;
  129. }
  130. while(string[idx] == seperator && idx < len) idx++;
  131. return ret;
  132. }
  133.  
  134.  
  135.  
  136.  
  137. ReturnUser(text[], playerid = INVALID_PLAYER_ID)
  138. {
  139. new pos = 0;
  140. while (text[pos] < 0x21)
  141. {
  142. if (text[pos] == 0) return INVALID_PLAYER_ID;
  143. pos++;
  144. }
  145. new userid = INVALID_PLAYER_ID;
  146. if (IsNumeric(text[pos]))
  147. {
  148. userid = strval(text[pos]);
  149. if (userid >=0 && userid < MAX_PLAYERS)
  150. {
  151. if(!IsPlayerConnected(userid))
  152. {
  153. userid = INVALID_PLAYER_ID;
  154. }
  155. else
  156. {
  157. return userid;
  158. }
  159. }
  160. }
  161. new len = strlen(text[pos]);
  162. new count = 0;
  163. new name[MAX_PLAYER_NAME];
  164. for (new i = 0; i < MAX_PLAYERS; i++)
  165. {
  166. if (IsPlayerConnected(i))
  167. {
  168. GetPlayerName(i, name, sizeof (name));
  169. if (strcmp(name, text[pos], true, len) == 0)
  170. {
  171. if (len == strlen(name))
  172. {
  173. return i;
  174. }
  175. else
  176. {
  177. count++;
  178. userid = i;
  179. }
  180. }
  181. }
  182. }
  183. if (count != 1)
  184. {
  185. if (playerid != INVALID_PLAYER_ID)
  186. {
  187. if (count)
  188. {
  189. SendClientMessage(playerid, Rojo, "[Error] Muchos jugadores alrededor.");
  190. }
  191. else
  192. {
  193. SendClientMessage(playerid, Rojo, "[Error] NingĂșn jugador concordante.");
  194. }
  195. }
  196. userid = INVALID_PLAYER_ID;
  197. }
  198. return userid;
  199. }
  200.  
  201. IsNumeric(const string[])
  202. {
  203. for (new i = 0, j = strlen(string); i < j; i++)
  204. {
  205. if (string[i] > '9' || string[i] < '0') return 0;
  206. }
  207. return 1;
  208. }
Advertisement
Add Comment
Please, Sign In to add comment