Respawn all vehicles bug
#1

Hello!

When I use /veh it spawns me a vehicle,and when i get out from vehicle and i use command /respawnallc (respawn all cars) it respawn all vehicles but the vehicle which i spawned using command /veh respawn at the place where i left it.I would like that when I respawn all vehicles also vehicles from command /veh would be respawned (deleted).

HERE are the both commands,so please if someone could fix it.I dont know how to fix it.

CMD :respawnallc

Код:
CMD:respawnallc(playerid, params[])
{
	#pragma unused params
  	if(pInfo[playerid][Adminlevel] < 4)return SendClientMessage(playerid,COLOR_RED,"[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
  	{
		new bool:vehicleused[MAX_VEHICLES];
		for(new i=0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
			{
				vehicleused[GetPlayerVehicleID(i)] = true;
			}
		}
		for(new i=1; i < MAX_VEHICLES; i++)
		{
			if(!vehicleused[i])
			{
				SetVehicleToRespawn(i);
			}
		}
		new msg[128], pName[MAX_PLAYERS];
		GetPlayerName(playerid, pName, sizeof(pName));
		format(msg, sizeof(msg), "[ADMIN]{FFFFFF} %s has respawned all unused vehicles.", pName);
		SendClientMessageToAll(COLOR_ADMIN, msg);
	}
	return 1;
}
CMD :veh

Код:
CMD:veh(playerid,params[])
{
	if(pInfo[playerid][Adminlevel] < 1)return SendClientMessage(playerid,COLOR_RED,"[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
	{
		new car;
		new string[128];
		new Float:X, Float:Y, Float:Z;
		GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
		if(sscanf(params,"i", car)) return SendClientMessage(playerid,0xff0000ff,"USAGE: /Veh <Vehicle ID 400 - 611>");
		else if(car < 400 || car >611) return SendClientMessage(playerid, 0xff0000ff, "ERROR: Cannot go under 400 or above 611.");
		{
		if(Vehicle[playerid] != 0)
		    {
		        DestroyVehicle(Vehicle[playerid]);
		    }
		    Vehicle[playerid] = CreateVehicle(car, X, Y, Z + 2.0, 0, -1, -1, 1);
		    format(string,sizeof(string),"You Have Spawned Vehicle ID %i",car);
		    SendClientMessage(playerid, 0xffffffff, string);
		    PutPlayerInVehicle(playerid, Vehicle[playerid], 0);
		}
	}
	return 1;
}
Reply
#2

pawn Код:
CMD:respawnallc(playerid, params[])
{
    #pragma unused params
    if(pInfo[playerid][Adminlevel] < 4)return SendClientMessage(playerid,COLOR_RED,"[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
    {
        new bool:vehicleused[MAX_VEHICLES];
        for(new i=0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
            {
                vehicleused[GetPlayerVehicleID(i)] = true;
            }
        }
        for(new i=1; i < MAX_VEHICLES; i++)
        {
            if(!vehicleused[i])
            {
                SetVehicleToRespawn(i);
            }
        }
        if(Vehicle[playerid] != 0)
        {
            DestroyVehicle(Vehicle[playerid]);
        }      
        new msg[128], pName[MAX_PLAYERS];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(msg, sizeof(msg), "[ADMIN]{FFFFFF} %s has respawned all unused vehicles.", pName);
        SendClientMessageToAll(COLOR_ADMIN, msg);
    }
    return 1;
}
Reply
#3

Is there any destroycars command in your script
Reply
#4

Quote:
Originally Posted by Danyal
Посмотреть сообщение
pawn Код:
CMD:respawnallc(playerid, params[])
{
    #pragma unused params
    if(pInfo[playerid][Adminlevel] < 4)return SendClientMessage(playerid,COLOR_RED,"[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
    {
        new bool:vehicleused[MAX_VEHICLES];
        for(new i=0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
            {
                vehicleused[GetPlayerVehicleID(i)] = true;
            }
        }
        for(new i=1; i < MAX_VEHICLES; i++)
        {
            if(!vehicleused[i])
            {
                SetVehicleToRespawn(i);
            }
        }
        if(Vehicle[playerid] != 0)
        {
            DestroyVehicle(Vehicle[playerid]);
        }      
        new msg[128], pName[MAX_PLAYERS];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(msg, sizeof(msg), "[ADMIN]{FFFFFF} %s has respawned all unused vehicles.", pName);
        SendClientMessageToAll(COLOR_ADMIN, msg);
    }
    return 1;
}
Still not working.Its still the same!
Reply
#5

New /veh command:
pawn Код:
CMD:veh(playerid,params[])
{
    if(pInfo[playerid][Adminlevel] < 1) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
    new car;
    if(sscanf(params,"i", car)) return SendClientMessage(playerid,0xff0000ff,"USAGE: /Veh <Vehicle ID 400 - 611>");
    if(car < 400 || car > 611) return SendClientMessage(playerid, 0xff0000ff, "ERROR: Cannot go under 400 or above 611.");
    new string[128], Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    if(Vehicle[playerid] != INVALID_VEHICLE_ID) DestroyVehicle(Vehicle[playerid]);
    Vehicle[playerid] = CreateVehicle(car, X, Y, Z + 2.0, 0, -1, -1, 1);
    format(string,sizeof(string),"You Have Spawned Vehicle ID %i",car);
    SendClientMessage(playerid, 0xffffffff, string);
    PutPlayerInVehicle(playerid, Vehicle[playerid], 0);
    return 1;
}
OnPlayerDisconnect and OnPlayerConnect:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    if(Vehicle[playerid] != INVALID_VEHICLE_ID)
    {
        DestroyVehicle(Vehicle[playerid]);
        Vehicle[playerid] = INVALID_VEHICLE_ID;
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    Vehicle[playerid] = INVALID_VEHICLE_ID;
    return 1;
}
/respawnallc command (This command will destroy all player-spawned vehicles):
pawn Код:
CMD:respawnallc(playerid, params[])
{
    #pragma unused params
    if(pInfo[playerid][Adminlevel] < 4) return SendClientMessage(playerid,COLOR_RED,"[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
    new bool:vehicleused[MAX_VEHICLES], i;
    for(i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(Vehicle[i] != INVALID_VEHICLE_ID)
        {
            DestroyVehicle(Vehicle[i]);
            Vehicle[i] = INVALID_VEHICLE_ID;
        }
        if(!IsPlayerInAnyVehicle(i)) continue;
        vehicleused[GetPlayerVehicleID(i)] = true;
    }
    for(i = 0; i < MAX_VEHICLES; i++)
    {
        if(vehicleused[i] == true) continue;
        SetVehicleToRespawn(i);
    }
    new msg[80], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(msg, sizeof(msg), "[ADMIN]{FFFFFF} %s has respawned all unused vehicles.", pName);
    SendClientMessageToAll(COLOR_ADMIN, msg);
    return 1;
}
Reply
#6

@BenzoAMG

This is also not working!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)