Car Syst Bug
#1

Hello, i wan't that when i am not car owner, i get dropped out of the car and get message, now i trying to do tis. Code :

Код:
if(strcmp(MasinosI[vehicleid][Owner],GetPlayerNameEx(playerid))) return SendClientMessage(playerid, -1,draudimas), RemovePlayerFromVehicle(playerid),format(draudimas,sizeof(draudimas),"This Car owner is : %s" ,MasinosI[vehicleid][Owner]);
I put this code in this calback :

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
When i get into car when i am not this car owner,then nothing. Just not working. What is wrong here ?

Sry for bad english.
Reply
#2

BUMP
Reply
#3

BUMP
Reply
#4

You should put it under OnPlayerStateChange.
When you place it under OnPlayerEnterVehicle, your code will eject players from a vehicle they haven't entered yet, as this callback is called whenever a player presses the ENTER button to enter the vehicle.
Their character is still walking towards the vehicle and can't be ejected yet.

Code from my own script, which works fine:
pawn Код:
// This callback gets called when the player changes state
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    // Setup local variables
    new vid, Name[24], Msg[128], engine, lights, alarm, doors, bonnet, boot, objective;

    switch (newstate)
    {
        case PLAYER_STATE_DRIVER: // Player became the driver of a vehicle
        {
            // Get the ID of the player's vehicle
            vid = GetPlayerVehicleID(playerid);
            // Get the player's name (the one who is trying to enter the vehicle)
            GetPlayerName(playerid, Name, sizeof(Name));

            // Check if the vehicle is owned
            if (AVehicleData[vid][Owned] == true)
            {
                // Check if the vehicle is owned by somebody else (strcmp will not be 0)
                if (strcmp(AVehicleData[vid][Owner], Name, false) != 0)
                {
                    // Force the player out of the vehicle
                    RemovePlayerFromVehicle(playerid);
                    // Turn off the lights and engine
                    GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
                    SetVehicleParamsEx(vid, 0, 0, alarm, doors, bonnet, boot, objective);
                    // Let the player know he cannot use somebody else's vehicle
                    format(Msg, 128, TXT_SpeedometerCannotUseVehicle, AVehicleData[vid][Owner]);
                    SendClientMessage(playerid, 0xFFFFFFFF, Msg);
                }
You should be able to convert this code to your own code.
Reply
#5

Thank you for ur replay I will chechk it later
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)