/vrespawn
#1

So, i've got the command working, but once i type it ingame i get:

All Current unocupied vehicles have been respawned.
SERVER: Unknown Command

I know this is because of a 'return 1;' but once i add return 1; to the command the command no longer respawns cars.
Here is my code:

Help would be very nice.
Reply
#2

Not tested

Код:
dcmd_vrespawn(playerid, params[])
{
	#pragma unused params
	if(IsPlayerConnected(playerid))
	{
		new aLevel = dini_Int(GetPlayer(playerid), "admin");
		if (aLevel > 1)
		{
			new bool:CarNotWanted[MAX_VEHICLES];
			for(new i=0; i <MAX_PLAYERS; i++)
			{
				if(IsPlayerInAnyVehicle(i))
				{
					CarNotWanted[GetPlayerVehicleID(i)]=true;
				}
			}
			for(new v = 1; v <= MAX_VEHICLES; v++)
			{
				if(!CarNotWanted[v])
				{
					SetVehicleToRespawn(v);
				}
			}
			SendClientMessageToAll(COLOR_ORANGE, "All current unocupied vehicles have been respawned.");
		}
		else
		{
      SendClientMessage(playerid, COLOR_WHITE, "You are not admin.");
      return 1;
		}
	}
	return 1;
}
Should work..
Reply
#3

Thanks for the reply, but this is still not working, now it wont display the 'All current unocupied vehicles have been respawn'.
Getting annoying :P
Reply
#4

Ok, well i found this around the forums..

Код:
if(strcmp("/respawnallcars", cmdtext, true) == 0 || strcmp("/rac", cmdtext, true) == 0)
	{
	  if(IsPlayerConnected(playerid)) {
	    if(PlayerInfo[playerid][Level] < 5) {
			  SendClientMessage(playerid, red, "Error: you are not authorized to use this command");
			  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 <= 268; car++) if(!unwanted[car]) SetVehicleToRespawn(car);

			format(stringy, sizeof(stringy), "All unused cars have been respawned by %s", PlayerInfo[playerid][Name]);
			SendClientMessageToAll(orange, stringy);
		}
		return 1;
	}
Reply
#5

Nice find, i just edited a little and its working perfect thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)