OnPlayerEnterVehicle Problem[Need Help]
#1

Hi!

I have this defined at the top of my script:
pawn Код:
new Car;
And this...
pawn Код:
Car = AddStaticVehicle(445,-2030.2690,156.5357,28.7109,181.0816,43,43); // car pos

Also this...
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(Car)
    {
      SendClientMessage(playerid,COLOR_ORANGE,"Server: You have the car, take it back to base");
      new pname[MAX_PLAYER_NAME];
      new string[128];
        GetPlayerName(playerid,pname,sizeof(pname));
        format(string,sizeof(string),"Server: %s (id:%d) has the car and is now taking it back to base!",pname,playerid);
        SendClientMessageToAll(COLOR_ORANGE,string);
    }
    return 1;
}
The problem is... it sends the message to everyone everytime they enter any car.
I only want this message to be sent when they get into the car defined as "car". Plz help me with this as it is so confusing :S

P.S If you need more info or dont understand, just ask
Reply
#2

Why did u do the function:

SendCientMessageToAll

you need only SendClientMessage(playerid,COLOR_ORANGE,string);
Reply
#3

AddStaticVehicle doesn't return the vehicles id. Use CreateVehicle() or AddStaticVehicleEx().
And
pawn Код:
if(Car == vehicleid)
Reply
#4

try this,
Quote:
Originally Posted by dice7
AddStaticVehicle doesn't return the vehicles id. Use CreateVehicle() or AddStaticVehicleEx().
And
pawn Код:
if(Car == vehicleid)
damn you beat me.
Reply
#5

Ok! That helped, but now, I only want the vehicle to respawn 5 secs after someone exits it...
Reply
#6

SetTimerEx + SetVehicleToRespawn
Reply
#7

How would I use them, like what sort of function would I have to make?
Reply
#8

Quote:
Originally Posted by dice7
AddStaticVehicle doesn't return the vehicles id.
AddStaticVehicle does return vehicleid.

Quote:
Originally Posted by Tigerbeast11
Ok! That helped, but now, I only want the vehicle to respawn 5 secs after someone exits it...
Just use AddStaticVehicleEx. https://sampwiki.blast.hk/wiki/AddStaticVehicleEx
Reply
#9

Ok!
I have done everything!

But I have one more question. i have to teams, attackers who steal the car and defenders who protect it... How can i make it so that if a defender presses enter near a car, he dies?

How can i stop the defender from getting in the car? No, i will not use "RemovePlayerFromVehicle", i want to stop the player from entering the vehicle in the first place!
Reply
#10

Quote:
Originally Posted by Tigerbeast11
Ok!
I have done everything!

But I have one more question. i have to teams, attackers who steal the car and defenders who protect it... How can i make it so that if a defender presses enter near a car, he dies?

How can i stop the defender from getting in the car? No, i will not use "RemovePlayerFromVehicle", i want to stop the player from entering the vehicle in the first place!
LOL I randomly came to this topic to make a gamemode to you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)