toribio

toribio

May 28th, 2009
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.10 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], barreiraid;
  9.     if(barcount[playerid] < 10)
  10.     {
  11.         GetPlayerPos(playerid, x, y, z);
  12.         GetPlayerFacingAngle(playerid, a);
  13.         GetXYInFrontOfPlayer(playerid, x, y, 1.0);
  14.         for(new i; i < sizeof barreira[playerid]; i++)
  15.         {
  16.             if(!barreira[playerid])
  17.             {
  18.                 barreiraid = i;
  19.                 break;
  20.             }
  21.         }
  22.         barreira[playerid][barreiraid] = CreateObject(981, x, y,z, 0.0, 0.0, a);
  23.         format(string, sizeof string, "ID dessa barreira: %d; Use \"/dbarreira %d\" para destruοΏ½-la.", barreiraid, barreiraid);
  24.         SendClientMessage(playerid, 0xFF0000AA, string);
  25.         barcount[playerid]++;
  26.     } else {
  27.         SendClientMessage(playerid, 0xFF0000AA, "VocοΏ½ jοΏ½ criou 10 barreiras, destrua uma com /dbarreira");
  28.     }
  29.     return 1;
  30. }
  31.  
  32. if(!strcmp(cmd, "/dbarreira", true))
  33. {
  34.     new tmp[256], barreiraid;
  35.     tmp = strtok(cmdtext, idx);
  36.     if(!strlen(tmp))
  37.         return SendClientMessage(playerid, 0xFFFFFFAA, "USE: /dbarreira [id_barreira]");
  38.     barreiraid = strval(tmp);
  39.     if(0 <= barreiraid < 10)
  40.     {
  41.         if(barreira[playerid][barreiraid])
  42.         {
  43.             DestroyObject(barreira[playerid][barreiraid]);
  44.             barreira[playerid][barreiraid] = 0;
  45.             barcount[playerid]--;
  46.         } else {
  47.             SendClientMessage(playerid, 0xFF0000AA, "ID de barreira nοΏ½o criada!");
  48.         }
  49.     } else {
  50.         SendClientMessage(playerid, 0xFF0000AA, "ID de barreiras entre 0 e 9!");
  51.     }
  52.     return 1;
  53. }
  54.  
  55. //no OnPlayerDisconnect:
  56. for(new i; i < sizeof barreira[playerid]; i++)
  57. {
  58.     if(barereira[playerid][i])
  59.         DestyroyObject(barereira[playerid][i]);
  60.     barereira[playerid][i] = 0;
  61. }
  62. barrcount[playerid] = 0;
  63.  
  64. //no fim do mode:
  65. stock GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
  66. {   // Created by Y_Less
  67.  
  68.     new Float:a;
  69.  
  70.     GetPlayerPos(playerid, x, y, a);
  71.     GetPlayerFacingAngle(playerid, a);
  72.  
  73.     if (GetPlayerVehicleID(playerid)) {
  74.         GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
  75.     }
  76.  
  77.     x += (distance * floatsin(-a, degrees));
  78.     y += (distance * floatcos(-a, degrees));
  79. }
Add Comment
Please, Sign In to add comment