Advertisement
toribio

toribio

May 27th, 2009
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.56 KB | None | 0 0
  1. //no topo:
  2. new barreira[MAX_PLAYERS][10]; //10 barreiras por jogador
  3. new barcount[MAX_PLAYERS];
  4.  
  5. //comandos:
  6. if(!strcmp(cmdtext, "/barreira", true))
  7. {
  8.     new Float:x, Float:y, Float:z, Float:a, string[128];
  9.     if(barcount[playerid] < 10)
  10.     {
  11.         GetPlayerPos(playerid, x, y, z);
  12.         GetPlayerFacingAngle(playerid, a);
  13.         GetXYInFrontOfPlayer(playerid, x, y, 1.0);
  14.         barreira[playerid][barcount[playerid]] = CreateObject(981, x, y,z, 0.0, 0.0, a);
  15.         format(string, sizeof string, "ID dessa barreira: %d; Use \"/dbarreira %d\" para destruí-la.", barcount[playerid], barcount[playerid]);
  16.         SendClientMessage(playerid, 0xFF0000AA, string);
  17.         barcount[playerid]++;
  18.     } else {
  19.         SendClientMessage(playerid, 0xFF0000AA, "Você já criou 10 barreiras, destrua uma com /dbarreira");
  20.     }
  21.     return 1;
  22. }
  23.  
  24. if(!strcmp(cmd, "/dbarreira", true))
  25. {
  26.     new tmp[256], barreiraid;
  27.     if(!strlen(tmp))
  28.         return SendClientMessage(playerid, 0xFFFFFFAA, "USE: /dbarreira [id_barreira]");
  29.     barreiraid = strval(tmp);
  30.     if(0 <= barreiraid < 10)
  31.     {
  32.         if(barreira[playerid][barreiraid])
  33.         {
  34.             DestroyObject(barreira[playerid][barreiraid]);
  35.             barreira[playerid][barreiraid] = 0;
  36.             barcount[playerid]--;
  37.         } else {
  38.             SendClientMessage(playerid, 0xFF0000AA, "ID de barreira não criada!");
  39.         }
  40.     } else {
  41.         SendClientMessage(playerid, 0xFF0000AA, "ID de barreiras entre 0 e 9!");
  42.     }
  43.     return 1;
  44. }
  45.  
  46. //no OnPlayerDisconnect:
  47. for(new i; i < sizeof barreira[playerid]; i++)
  48. {
  49.     if(barereira[playerid][i])
  50.         DestyroyObject(barereira[playerid][i]);
  51.     barereira[playerid][i] = 0;
  52. }
  53. barrcount[playerid] = 0;
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement