Detect Passenger & Unknown command
#7

You dont need 2 times loop for MAX_PLAYERS

pawn Код:
if(strcmp(cmdtext, "/tower", true) == 0)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        new PlayerID[50],SeatID[50],cnt,i;
        for(i = 0; i < MAX_PLAYERS; i++)
        {
            if(!IsPlayerConnected(i)) continue;
            if(i == playerid) continue;
            if(GetPlayerVehicleID(i) != vehicleid) continue;
            new VSeat = GetPlayerVehicleSeat(i);
            PlayerID[cnt] = i;
            SeatID[cnt] = (-1 < VSeat < sizeof(PlayerID)) ? VSeat : cnt+1;
            ++cnt;
        }
        SetVehiclePos(vehicleid, 1544.2318, -1354.3735, 329.4725);
        SetVehicleZAngle(vehicleid, 100.0);
        for(i = 0; i < cnt; i++)
            PutPlayerInVehicle(PlayerID[i], vehicleid, SeatID[i]);
    }
    return 1;
}
// EDIT

Wrong placed return 1; so unknown command appears

pawn Код:
if(strcmp(cmdtext, "/tower", true) == 0)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        SetVehiclePos(vehicleid, 1544.2318, -1354.3735, 329.4725);
        SetVehicleZAngle(vehicleid, 100);
    }
    else
    {
        SetPlayerPos(playerid, 1541.3450,-1366.5369,329.7969);
        SetPlayerFacingAngle(playerid, 360);
    }
    return 1;
}
Reply


Messages In This Thread
Detect Passenger & Unknown command - by Kophaer - 09.12.2013, 08:38
Re: Detect Passenger & Unknown command - by park4bmx - 09.12.2013, 09:06
Re: Detect Passenger & Unknown command - by Vince - 09.12.2013, 09:25
Re: Detect Passenger & Unknown command - by Kophaer - 09.12.2013, 10:55
Re: Detect Passenger & Unknown command - by Threshold - 09.12.2013, 10:58
Re: Detect Passenger & Unknown command - by Kophaer - 09.12.2013, 14:52
Re: Detect Passenger & Unknown command - by Jefff - 09.12.2013, 16:46
Re: Detect Passenger & Unknown command - by Threshold - 09.12.2013, 21:12
Re: Detect Passenger & Unknown command - by Jefff - 09.12.2013, 22:04
Re: Detect Passenger & Unknown command - by Threshold - 10.12.2013, 01:09

Forum Jump:


Users browsing this thread: 2 Guest(s)