Need help with a string - 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: Need help with a string (
/showthread.php?tid=551203)
Need help with a string -
Jing_Chan - 17.12.2014
pawn Код:
CMD:respawnallcars(playerid)
{
new string[128];
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] < 2)
{
SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to do this!");
return 1;
}
new bool:unwanted[MAX_VEHICLES];
for(new player=0; player<MAX_PLAYERS; player++)
{
if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
}
for(new car = 1; car <= MAX_VEHICLES; car++)
{
if(!unwanted[car]) SetVehicleToRespawn(car);
}
format(string, sizeof(string), "SERVER: All unused cars were respawned by %s", sendername);
SendClientMessageToAll(COLOR_YELLOW, string);
}
return 1;
}
The command works but the string doesn't send, help please
Re: Need help with a string -
Misiur - 17.12.2014
Because your server crashes with out of bounds error. Install crashdetect to see for yourself.
Either start counting cars from 0:
pawn Код:
for(new car = 0; car < MAX_VEHICLES; car++)
{
if(!unwanted[car]) SetVehicleToRespawn(car + 1);
}
Or sacrifice slot 0 in your array to be unused and add one slot more.
pawn Код:
new bool:unwanted[MAX_VEHICLES + 1];
Re: Need help with a string -
Jing_Chan - 17.12.2014
Quote:
Originally Posted by Misiur
Because your server crashes with out of bounds error. Install crashdetect to see for yourself.
Either start counting cars from 0:
pawn Код:
for(new car = 0; car < MAX_VEHICLES; car++) { if(!unwanted[car]) SetVehicleToRespawn(car + 1); }
Or sacrifice slot 0 in your array to be unused and add one slot more.
pawn Код:
new bool:unwanted[MAX_VEHICLES + 1];
|
So, changing it to 0 will make the string work?
Re: Need help with a string -
Misiur - 17.12.2014
Just test it. Yes, it will, BUT focus on this
pawn Код:
SetVehicleToRespawn(car + 1);
Your array indexes will be -1 in relation to samp vehicle identifiers.