Enter vehicles only with certain score -
BlackWolf120 - 10.01.2011
hi,
i just wrote down some code lines that shall prevent the use of vehicles to all players with a score lower than 50.
But its bugged up

Well for me it works but if therre are more players online it just doesnt work. The ClientMessage is always displayed right but the ejection system does not work correctly.
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new ValidScore;
ValidScore = GetPlayerScore(playerid);
if(ValidScore > 50)
{
SendClientMessage(playerid,0xAA3333AA,"{76EEC6}Drive {283A90}carefully.");
}
else
{
SetTimer("CarEjecter",1000,10);
SendClientMessage(playerid,0xAA3333AA,"{76EEC6}Your Score {551011}is not high enough to drive this {76EEC6}vehicle!");
}
return 1;
}
forward CarEjecter(playerid);
public CarEjecter (playerid)
{
if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER)
{
RemovePlayerFromVehicle(playerid);
}
}
regards...
Re: Enter vehicles only with certain score - [BEP]AcerPilot - 10.01.2011
You need to use SetTimerEx instead of SetTimer to tell to the public function the player id.
pawn Код:
SetTimerEx("CarEjecter", 1000, 0, "i", playerid);
Use this for more info:
wiki.sa-mp.com/wiki/SetTimerEx
Ah, and you don't need a variable to store the player's score. Use this optimization:
pawn Код:
if(GetPlayerScore(playerid) > 50)
// stuff here
Re: Enter vehicles only with certain score -
BlackWolf120 - 10.01.2011
thx AcerPilot

gonna try it out.
thx
regards..
Re: Enter vehicles only with certain score -
boelie - 10.01.2011
why dont you just use OnPlayerStateChange instead of the timer ?
Re: Enter vehicles only with certain score -
BlackWolf120 - 10.01.2011
never used that before

Could u give me a little example maybe?
AW: Enter vehicles only with certain score -
Kmitska - 10.01.2011
Instead of the timer you could use something else like
new Float

,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
SetPlayerPos(playerid,x,y,z+1); //Throws the player up
This script is like an eject command but you might use it.
Re: Enter vehicles only with certain score -
BlackWolf120 - 10.01.2011
if it just throws the player up i dont know if its very usefull in my case but thx

Id be happy if someone could give me a little expample with OnPlayerStateChange used otherwise i have to ****** it
Re: Enter vehicles only with certain score - [BEP]AcerPilot - 10.01.2011
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
if(GetPlayerScore(playerid) > 50)
{
SendClientMessage(playerid,0xAA3333AA,"{76EEC6}Drive {283A90}carefully.");
return 1;
}
else
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,0xAA3333AA,"{76EEC6}Your Score {551011}is not high enough to drive this {76EEC6}vehicle!");
return 1;
}
}
return 1;
}
With OnPlayerStateChange you don't need to use a timer, 'cause it will be called only when the player is inside the vehicle, not when he attempts to enter a vehicle.
Re: Enter vehicles only with certain score -
boelie - 10.01.2011
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(IsPlayerInAnyVehicle(playerid))
{
if (newstate == PLAYER_STATE_DRIVER)
{
if( ( your if playerscore thingy here
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_LIGHTRED, "yo cant drive because your score is to low!");
}
}
}
return 1;
}
have fun
[edit] damn i was to slowXD
Re: Enter vehicles only with certain score -
BlackWolf120 - 10.01.2011
thx soooo much for ur codes

Nice now ive got 2 versions

thx