Respawning all cars problem
#1

CMD:respawnallcars(playerid,params[])
{

if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
for(new v = 0; v < MAX_VEHICLES; v++)
{
SetVehicleToRespawn(v);
}
return 1;
}

I want if a player iz in the vehicle the car doesnt respawn any help?
Reply
#2

Here u go:
pawn Код:
CMD:respawnallcars(playerid,params[])
    {
        if(PlayerInfo[playerid][Level] <= 2)
        {
            new
            i,
            bool: vUsed[MAX_VEHICLES + 1];
            foreachex(Player, i)
            {
                vUsed[GetPlayerVehicleID(i)] = true;
            }
            for(i = 1; i <= MAX_VEHICLES; ++i) {
                if(!vUsed[i]) {
                    SetVehicleToRespawn(i);
                }
            }
            return true;
        }
        else
        {
            SendClientMessage(playerid,COLOR_GREY,"You are not authorized to use this command.");
            return 1;
        }
    }
Rep if i helped you
Reply
#3

use this i use it and is the best respawns only unused vehicles
Код:
if(strcmp(cmdtext, "/respawncars", true) == 0){
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF0000AA,"You can't use this command.");
    new vh=CreateVehicle(400,0.0,0.0,0.0,0.0,-1,-1,-1);
    DestroyVehicle(vh);
    new p[MAX_VEHICLES];
    for(new v = 0; v < vh; v++){
    p[v]=0;
    for(new i = 0; i < GetMaxPlayers(); i++){
    if(IsPlayerInVehicle(i,v)) p[v]=1;
}
	if(p[v]==0) SetVehicleToRespawn(v);
}
    new string[64], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    format(string,sizeof string,"Admin %s Has Respawned all Unused Cars!",pName);
    SendClientMessageToAll(lightgreen,string);
	return 1;
}
rep if this helped you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)