slap before getting in a car
#1

Hello guys,i want to make when you enter in a car and you dont have a drivers license,it slaps you,
i made it,but the problem is that the player gets into the car and then it slaps him,i want him to be slapped when he presses f,without him getting to open the door and getting in the car,how do i do that?

PHP код:
 if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER// Player entered a vehicle as a driver
    
{
        new 
vehicleid GetPlayerVehicleID(playerid);
        new 
carid FindSpawnID(vehicleid);
        if(
CarInfo[carid][cID] != -&& carid != 0)
        {
            
format(stringsizeof(string), "* Acest %s este detinut de %s."vehName[CarInfo[carid][cModel]-400],CarInfo[carid][cOwner]);
            
SendClientMessage(playeridCOLOR_WHITEstring);
        }
        new 
faction PlayerData[playerid][Member] + PlayerData[playerid][Leader];
        if(!(
IsAPlane(vehicleid) || IsABoat(vehicleid) || IsABike(vehicleid)))
        {
            if(
PlayerData[playerid][CarLic] == 0)
            {
            new 
Float:xFloat:yFloat:z;
            
GetPlayerPos(playeridxyz);
            
SetPlayerPos(playeridxyz+3);
            
SendClientMessage(playeridCOLOR_WHITE"You don't have a driving license");
            } 
Reply
#2

I'm not sure if you can entirely prevent opening the door, but take a look at https://sampwiki.blast.hk/wiki/OnPlayerEnterVehicle, which gets called when the player starts to enter a vehicle, not when he actually has entered it (as in your code with state checking)
Reply
#3

ok,now it works,but even if you press G you get knocked out.

how can i filter it to be just for drivers?

got this so far
PHP код:
if(!(IsAPlane(vehicleid) || IsABoat(vehicleid) || IsABike(vehicleid)))
        {
            if(
PlayerData[playerid][CarLic] == && StaticVeh[vehicleid][vSpecial] == 0)
            {
            new 
Float:xFloat:yFloat:z;
            
GetPlayerPos(playeridxyz);
            
SetPlayerPos(playeridxyz+3);
            
SendClientMessage(playeridCOLOR_WHITE"You don't have a driving license");
            }
            if(
PlayerData[playerid][CarLic] == && StaticVeh[vehicleid][vSpecial] == 15)
            {
              new 
Float:xFloat:yFloat:z;
            
GetPlayerPos(playeridxyz);
            
SetPlayerPos(playeridxyz+3);
            
SendClientMessage(playeridCOLOR_WHITE"You don't have a driving license");
            }
        } 
Reply
#4

Hello.
Use This.
PHP код:
if(IsPlayerInVehicle(playerid)) 
Reply
#5

for what?
i want to slap the player when he presses F,not G
Reply
#6

Write this in onplayerkeystatechange.
PHP код:
if(newkeys == 65536)
{
if(
IsPlayerInAnyVehicle(playerid))
{
     
RemovePlayerFromVehicle(playerid);
     new 
Float:xFloat:yFloat:z
     
GetPlayerPos(playeridxyz); 
     
SetPlayerPos(playeridxyz+3); 
}

P.S IT WILL WORKS ON KEY Y, CUZ I DONT KNOW F-s ID.
Reply
#7

https://sampwiki.blast.hk/wiki/OnPlayerEnterVehicle
Quote:

ispassenger 0 if entering as driver. 1 if entering as passenger.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)