Vehicle Respawning issues -
Zonoya - 04.08.2015
So, back again, this time, having issues with respawning cars...
Relevant code below:
Код:
CMD:rc(playerid, params[])
{
new count = 0, respawncount = 0, pcount = 0;
for(new i = 0; i < MAX_PLAYER_VEHICLES; i++) {
if(!strcmp(vInfo[i][vOwner], Name[playerid])) {
for(new u = 0; u < MAX_PLAYERS; u++) if(IsPlayerInVehicle(u, i)) pcount++;
if(pcount == 0) {
DestroyVehicle(vInfo[i][vCarID]);
vInfo[i][vCarID] = CreateVehicle(vInfo[i][vModel], vInfo[i][vLoc][0], vInfo[i][vLoc][1], vInfo[i][vLoc][2], vInfo[i][vLoc][3], vInfo[i][vCol1], vInfo[i][vCol2], -1);
respawncount++;
} count++;
}
}
if(count == 0) return SCM(playerid, SCM_C_YELLOW, "You have no vehicles!");
SCFM(playerid, SCM_C_YELLOW, "%d out of %d of your vehicles were respawned!", respawncount, pcount);
return 1;
}
The issue, is with the /rc command, it's meant to only respawn the cars the player owns, which it DOES do.
The issue, is with the counting, I've made a doo doo somewhere, but I'm too tired to pick up on it, when I own one car, and aren't driving it, it should say '1 out of 1 of your vehicles were respawned'
And when I am driving it, it should say '0 out of 1 of your vehicles were respawned'
The issue is, it's saying 999 out of 0 of your vehicles were respawned, 999 rings alarm bells to me, in that there's two cars in the server, one owned by me, and the other, a test account, the max player cars is 1000, so that's where 999 comes from, but it's just not working right, and I kind of now need help fixing it...
Thanks, Zon.
Re: Vehicle Respawning issues -
jamesbond007 - 04.08.2015
jesus christ that indentation.. why not make it easy for yourself and align brackets
Re: Vehicle Respawning issues -
Zonoya - 05.08.2015
Quote:
Originally Posted by jamesbond007
jesus christ that indentation.. why not make it easy for yourself and align brackets
|
I usually do, but give me a break, it was midnight when I wrote that code.
I fixed the indentation on my end this morning, when I was more with it, but I still can't see my issue.
Also, the indentation there is just because I copy-pasted it onto a browser, it's indented and all aligned fine on the actual script now, but that doesn't fix my issue, which, I just cannot seem to fix.