SA-MP Forums Archive
onplayerentervehicle - 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: onplayerentervehicle (/showthread.php?tid=501625)



onplayerentervehicle - Extraordinariness - 19.03.2014

My codei've inserted my own enum)
pawn Код:
new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    if(GetVehicleModel(vehicleid) == 425 && pInfo[playerid][Scores] < 5000)
    {
        SendClientMessage(playerid, 0xFF0000FF, "You need 5000 score to drive the Hunter!"); SetPlayerPos(playerid, X, Y, Z);
    }
Now I've experimented if it works. I've set my score to 5000, and 10000. None of them worked. How do I?


Re: onplayerentervehicle - MP2 - 19.03.2014

Why not use GetPlayerScore instead of pInfo[playerid][Scores]?


Re: onplayerentervehicle - Extraordinariness - 19.03.2014

ok. lemme try that.
________________
thanks. it worked.


Re: onplayerentervehicle - MP2 - 19.03.2014

You should remove all traces of the 'Scores' variable/enum, as it's useless when you have GetPlayerScore.


Re: onplayerentervehicle - VishvaJeet - 19.03.2014

Use it under OnplayerUpdate()
Код:
      
public OnPlayerUpdate(playerid)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    new vid = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vid) == 425 && GetPlayerScore(playerid) < 5000)
    {
        SendClientMessage(playerid, 0xFF0000FF, "You need 5000 score to drive the Hunter!"); 
        SetPlayerPos(playerid, X, Y, Z+1);
    }
   return 1;
}



Re: onplayerentervehicle - MP2 - 19.03.2014

That is NOT something you would put under OnPlayerUpdate. You only need to check it when they get in a hunter, not ~30 times a second. That's ridiculous.


Re: onplayerentervehicle - Knappen - 19.03.2014

I agree with MP2, why would you check it under OnPlayerUpdate, when OnPlayerEnterVehicle is available? Instead of making the server constantly check if he's in that vehicle, and if his score is more than 5000, he can just check the moment he enters the vehicle.

My guess is that when you set someones score, you use "SetPlayerScore" without setting the pInfo[playerid][Scores]. I'd do like MP2 said. Use SetPlayerScore and GetPlayerScore.