command makes cars and everything bugged
#1

When i use that command, for respawning all cars, the server comes stuck for a 2-3 minutes, then after everything goes wrong, the cars arent starting, 3d text doesnt disappear, and so on.
Is there any other alternatives for this command which work on 0.3x?
Код:
if(strcmp(cmd, "/rescar", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pAdmin] < 3)
			{
			    SendClientMessage(playerid, COLOR_GRAD1, "U have no permission!");
			    return 1;
			}
			new bool:unwanted[CAR_AMOUNT];
			for(new player=0; player<MAX_PLAYERS; player++)
     		{
            	if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
     		}
			for(new car = 1; car <= 2000; car++)
			{
				if(!unwanted[car])
				{
					SetVehicleToRespawn(car);
				}
			}
			GetPlayerName(playerid,sendername,MAX_PLAYER_NAME);
			format(string,sizeof(string), " * Cars have been respawned by admin %s",sendername);
			SendClientMessageToAll(COLOR_LIGHTRED, string);
		}
		return 1;
	}
Reply
#2

format(string,sizeof(string), " * Cars have been respawned by admin",sendername);
is wrong. You use sendername without having a '%s' in the string. (assuming sendername is a string)
Reply
#3

its not the problem, i just translated the command from my native language to english and forgot it =/
Reply
#4

You define
new bool:unwanted[CAR_AMOUNT];

and then you use
for(new car = 1; car <= 2000; car++)

Most likely CAR_AMOUNT is smaller or equal to 2000 and you try to read unwanted[CAR_AMOUNT or higher]

try
for(new car = 1; car < CAR_AMOUNT; car++)

notice it's < not <= because an array of the size 2000 starts with 0 and goes to 1999 only
Reply
#5

okay ill try, but everything was ok in the last versions
Reply
#6

thanks much, everything is ok now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)