Specific vehicles respawn
#1

Hello.

I made a command which will allow faction leader to respawn faction vehicles. When I test command IG it returns me 'SERVER: Unknown Command', but it respawns some of the faction vehicles (not all) and also some random other vehicles.

Here is the script:
pawn Код:
if(strcmp(cmd, "/respawnf", true) == 0)
    {
        if (PlayerInfo[playerid][pRank] == 1 && PlayerInfo[playerid][pFaction] != 255)
        {
            for(new i=0;i<MAX_VEHICLES;i++)
            {
                if(IsVehicleOccupied(i) == 0)
            {
                    if(PlayerInfo[playerid][pFaction] == DynamicCars[i][FactionCar])
                    {
                        SetVehicleToRespawn(i);
                    }
                }
            }
            format(string, sizeof(string), "%s has just respawned faction vehicles.", GetPlayerNameEx(playerid));
            SendFactionMessage(PlayerInfo[playerid][pFaction], COLOR_LIGHTRED, string);
        }
        else
        {
            SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] You are not a leader!");
        }
        return 1;
    }
What am I doing wrong here?

Thanks for help.
Reply
#2

Have you tried adding debug messages?
Reply
#3

I made this:
pawn Код:
if(strcmp(cmd, "/respawnf", true) == 0)
    {
printf("Test 1");
        if (PlayerInfo[playerid][pRank] == 1 && PlayerInfo[playerid][pFaction] != 255)
        {
printf("Test 2");
            for(new i=0;i<MAX_VEHICLES;i++)
            {
printf("Test 3");
                if(IsVehicleOccupied(i) == 0)
            {
printf("Test 4");
                    if(PlayerInfo[playerid][pFaction] == DynamicCars[i][FactionCar])
                    {
printf("Test 5");
                        SetVehicleToRespawn(i);
                    }
                }
            }
printf("Test 6");
            format(string, sizeof(string), "%s has just respawned faction vehicles.", GetPlayerNameEx(playerid));
            SendFactionMessage(PlayerInfo[playerid][pFaction], COLOR_LIGHTRED, string);
        }
        else
        {
            SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] You are not a leader!");
        }
        return 1;
    }
and the result is:
Код:
[14:46:20] Test 1
[14:46:20] Test 2
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 5
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 5
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 5
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 5
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 5
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 5
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 5
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 5
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 5
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 5
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:20] Test 3
[14:46:20] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 5
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
[14:46:21] Test 3
[14:46:21] Test 4
Reply
#4

Try that, not sure if it works.
It might also just be that your DynamicVehicles faction vehicles array is not properly working.

pawn Код:
if(strcmp(cmd, "/respawnf", true) == 0)
{
    if (PlayerInfo[playerid][pRank] == 1 && PlayerInfo[playerid][pFaction] != 255)
    {
        for(new i=0;i<MAX_VEHICLES;i++)
        {
            if(IsVehicleOccupied(i) == 0)
            {
                if(PlayerInfo[playerid][pFaction] == DynamicCars[i][FactionCar])
                {
                    SetVehicleToRespawn(i);
                }
            }
        }
        format(string, sizeof(string), "%s has just respawned faction vehicles.", GetPlayerNameEx(playerid));
        SendFactionMessage(PlayerInfo[playerid][pFaction], COLOR_LIGHTRED, string);
        return 1;
    }
    else return SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] You are not a leader!");
}
Reply
#5

It still doesn't work :/
DynamicCars[i ][FactionCar] works in all other cases, so it would be strange that it wouldn't work only here.
Reply
#6

I made it workable now, but there is another problem. Current script is this:
pawn Код:
if(strcmp(cmd, "/respawnf", true) == 0)
    {
        if (PlayerInfo[playerid][pRank] == 1 && PlayerInfo[playerid][pFaction] != 255)
        {
            format(string, sizeof(string), "%s has just respawned faction vehicles.", GetPlayerNameEx(playerid));
            SendFactionMessage(PlayerInfo[playerid][pFaction], COLOR_LIGHTRED, string);
            for(new i=0;i<MAX_VEHICLES;i++)
            {
                if(DynamicCars[i][FactionCar] != 255)
            {
              if(DynamicCars[i][FactionCar] == PlayerInfo[playerid][pFaction])
              {
                        if(IsVehicleOccupied(i+1) == 0)
                        {
                            SetVehicleToRespawn(i+1);
                        }
                    }
                }
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] You are not a leader!");
        }
        return 1;
    }
It respawns right vehicles and also show up the message, but behind everything it displays 'SERVER: Unknown Command'.

What could be the solution to fix?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)