SA-MP Forums Archive
eehm got little problem with onentercar - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: eehm got little problem with onentercar (/showthread.php?tid=308216)



eehm got little problem with onentercar - niels44 - 02.01.2012

hey guys,
i have made this kind of dialog that when a player enters a car they get a little dialog msg box which says that they have to pay road tax to drive on the roads and it works fine but now i found a little bugg and i dont know how to fix it...
everytime u enter a car u get a dialog which says if u want to pay or not pay and that part is working fine but then when ur driving or walking and someone else gets in a car then he gets the dialog too but the one who is walking gets it too... how can i make it that only the player who enters the car gets the dialog and not everyone when 1 player enters a car...
this are my codes:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    SetTimer("CarDialog", 3000, false);
    return 1;
}
public CarDialog(playerid)
{
    ShowPlayerDialog(playerid, 12345, DIALOG_STYLE_MSGBOX, "Car Tax", "to drive this vehicle you have to pay $10000 for the Road Tax!", "Pay", "Don't Pay");
    return 1;
}
pawn Код:
if(dialogid == 12345){
        if(response){
        GivePlayerMoney(playerid, -10000);
        }
        else{
            RemovePlayerFromVehicle(playerid);
        }
    }
eehm can someone help me pls
niels


Re: eehm got little problem with onentercar - Jakku - 02.01.2012

Why do you use a timer, when you can use OnPlayerStateChange? Like this:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
       ShowPlayerDialog(playerid, 12345, DIALOG_STYLE_MSGBOX, "Car Tax", "to drive this vehicle you have to pay $10000 for the Road Tax!", "Pay", "Don't Pay");
    }
    return 1;
}



Re: eehm got little problem with onentercar - niels44 - 02.01.2012

eehm and thsi is working...? this isnt doing wut i had as bugg? and i used the timer becuz then the dialog appears when the player is sitting in the car and not have to sit in teh car anyway thnx i will test now if it works..
hmm could u else join my server now to test it with me together?: 86.88.158.170:7777


Re: eehm got little problem with onentercar - Jakku - 02.01.2012

It will work. If you use a global timer instead of a local one (SetTimerEx), it will mix it between players. Try the one I posted, it will work.