Arrays problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Arrays problem (
/showthread.php?tid=528394)
Arrays problem -
FullCircle - 27.07.2014
I made 2 variables:
1_ PlayerVCantidad[MAX_PLAYERS] for store the total of player vehicles
2_ PlayerVehicle[MAX_PLAYERS][MAX_PLAYER_VEHICLES] for store playervehicles ids in differents arrays
I put this when player login, but doesn't work, when I use the test command print:
pawn Код:
new vv = 1;
for(new v = 1; v < MAX_VEHICLES; v ++)
{
if(strcmp(NombreJ(playerid), cInformacion[v][cOwner]) == 0) //This check if the player is Owner
{
vv ++
PlayerVehicle[playerid][vv] = v;
PlayerVCantidad[playerid] ++;
}
}
Command:
pawn Код:
CMD:TEST(playerid, params[])
{
new string[6];
for(new pv = 1; pv < MAX_PLAYER_VEHICLES; pv ++)
{
format(string, sizeof(string), "%d: %d", pv, PlayerVehicle[playerid][pv]);
SendClientMessage(playerid, -1, string);
}
return 1;
}
Re: Arrays problem -
Jefff - 27.07.2014
pawn Код:
new vv;
for(new v = 1; v < MAX_VEHICLES; v++)
{
if(cInformacion[v][cOwner][0] != '\0' && strcmp(NombreJ(playerid), cInformacion[v][cOwner]) == 0 && ++vv < MAX_PLAYER_VEHICLES) //This check if the player is Owner
{
PlayerVehicle[playerid][vv] = v;
PlayerVCantidad[playerid]++;
}
}
CMD:test(playerid, params[])
{
if(PlayerVCantidad[playerid] == 0) SendClientMessage(playerid,-1,"No vehicles owned");
else{
new string[10];
for(new pv = 1; pv < PlayerVCantidad[playerid]; pv++)
{
format(string, sizeof(string), "%d: %d", pv, PlayerVehicle[playerid][pv]);
SendClientMessage(playerid, -1, string);
}
}
return 1;
}
Respuesta: Re: Arrays problem -
FullCircle - 27.07.2014
Quote:
Originally Posted by Jefff
pawn Код:
new vv; for(new v = 1; v < MAX_VEHICLES; v++) { if(cInformacion[v][cOwner][0] != '\0' && strcmp(NombreJ(playerid), cInformacion[v][cOwner]) == 0 && ++vv < MAX_PLAYER_VEHICLES) //This check if the player is Owner { PlayerVehicle[playerid][vv] = v; PlayerVCantidad[playerid]++; } }
CMD:test(playerid, params[]) { if(PlayerVCantidad[playerid] == 0) SendClientMessage(playerid,-1,"No vehicles owned"); else{ new string[10]; for(new pv = 1; pv < PlayerVCantidad[playerid]; pv++) { format(string, sizeof(string), "%d: %d", pv, PlayerVehicle[playerid][pv]); SendClientMessage(playerid, -1, string); } } return 1; }
|
Doesn't work