Teleport/PutPlayerInVehicle() issue
#1

Ok, i have annoying problems about PutPlayerInVehicle(). The exact problem is that players sometimes don't get teleported / putted in a vehicle. Probably due lag, serverlag, high ping ?! Im trying to fix it;

I use the function in Teleport(). Paste: http://pastebin.com/RMDfJd4P

In the paste you see 3 ways i tried to fixed it, none worked.

If you have idea's to do it otherwise, post them here
Reply
#2

You're trying to put everyone in the same seat. You need to put them in different seats. Use this function and replace the 0 at the end of your PutPlayerInVehicle function with GetFreeVehicleSeat(tempCarID[tppedcar]).

pawn Код:
GetFreeVehicleSeat(vehicleid)
{
    new bool: vehicleSeatStatus[4];

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerVehicleID(i) == vehicleid)
        {
            vehicleSeatStatus[GetPlayerVehicleSeat(i)] = true;
        }
    }

    for(new i = 0; i < 4; i++)
    {
        if(vehicleSeatStatus[i] == true)
        {
            return i;
        }
    }

    return INVALID_VEHICLE_ID;
}
Also, you don't need to SetPlayerPos before PutPlayerInVehicle and you might want to include a check for when there's no free vehicle seat. This function returns INVALID_VEHICLE_ID in that case.
Reply
#3

Euh SuperViper, i think you miss understand ?
- Why should i need GetFreeVehicleSeat() when i have IsSomeoneInVehicle() ?

Quote:

You're trying to put everyone in the same seat.

No im not . It's all about a derby server if you didn't know. Every map has always 20 cars that has been created and loaded via a database. And i want to , in Teleport(), that every player gets his own vehicle to play with. I used that with PutPlayerInVehicle(), when the server was in beta fase, a lot of ppl gave critic about the teleport because they hadn't a vehicle to play with.

So it must be with PutPlayerInVehicle()
Reply
#4

Why people are going into a car sometimes, is because you are using random to get a vehicle ID.
But if people have the same random ID, then one of them will go into a car, and the other not.

A better way to grab a vehicle, is just going everytime to the next ID of the vehicle.
Example:
pawn Код:
forward Teleport();
public Teleport()
{
    new
        tppedcar,
        bool:loopFinished = false,
        NextCar = 0;
    Loop(i, MAX_PLAYERS)
    {
        if(IsPlayerConnected(i) && IsPlayerInRound[i] == 0)
        {
            tppedcar = NextCar;
            PutPlayerInVehicle(i, tempCarID[tppedcar], 0);
            IsPlayerInRound[i] = 1;
            #if DEBUG == true
            printf("[DEBUG] - [1st teleport]: %i spawned in car tempCarID[%d]", i, tppedcar);
            #endif
            NextCar++;
        }
       
    }
    loopFinished = true;
   
    #if DEBUG == true
    print("[DEBUG] - Teleport() called");
    #endif
}
Reply
#5

Hmm, that's looks fine. But that only fixed the "car jack problem" but i will use it. And it still doesn't work:

Код:
[18:43:08] [DEBUG] - 0 spawned in car tempCarID[0] 
[18:43:08] [DEBUG] - 1 spawned in car tempCarID[1] 

later:

[18:45:05] [DEBUG] - 1 spawned in car tempCarID[0] 

again later:

[18:46:29] [DEBUG] - 0 spawned in car tempCarID[0]
Was testing with 2 players, i was id 0 , the other id 1. And ye sometimes i didn't spawned again ...
Reply
#6

When and where are you calling Teleport();?
Reply
#7

Quote:
Originally Posted by BlackBank3
Посмотреть сообщение
When and where are you calling Teleport();?
Teleport() is called via a timer in LoadMap() , Loadmap() is called in Startround() and Startround() is called in OnGamemodeInit().

Paste: http://pastebin.com/RMDfJd4P
Reply
#8

*bump*
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)