Whats wrong with this? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Whats wrong with this? (
/showthread.php?tid=189189)
Whats wrong with this? -
iTorran - 10.11.2010
I have this code for my private cars. So if someone has lent someone a car they can drive it also..
This is my code:
pawn Код:
if(vehicleid == Torran[0])
{
if(strcmp(GetName(playerid), "JoeTorran", true) == 0 || strcmp(Lent[playerid], "Torran0", true) == 0)
{
print(" ");
}
else
{
RemovePlayerFromVehicle(playerid);
}
}
But if someone gets in my car. It dosent remove them like they have it lent to them.
Why? OnPlayerConnect i set Lent[playerid] to 0, Anything wrong with that code?
Re: Whats wrong with this? -
Hiddos - 10.11.2010
Are you using this code in the OnPlayerEnterVehicle callback? If so, it won't work. That callback (CB for short) gets called when the player presses the key for entering a vehicle ('F' by default), not when he actually 'enters' it. Use either OnPlayerStateChange with 'if(newstate == PLAYER_STATE_DRIVER && !strcmp(getname(playerid), "JoeTorran"))' or place the code on an even better place: OnVehicleStreamIn
pawn Код:
public OnVehicleStreamIn(vehicleid, forplayerid)
{
if(vehicleid == Torran[0])
{
if(strcmp(GetName(forplayerid), "JoeTorran") || strcmp(Lent[forplayerid], "Torran0")) return SetVehicleParamsForPlayer(vehicleid, forplayerid, 0, 1);
}
return 1;
}
PS: Hope that code works lol
Re: Whats wrong with this? -
iTorran - 10.11.2010
I use it OnPlayerStateChange.
But if delete the Lent bit then it all works
Re: Whats wrong with this? -
Hiddos - 10.11.2010
Could you show us any code about the 'Lent' bit?
Re: Whats wrong with this? -
iTorran - 10.11.2010
Quote:
Originally Posted by Hiddos
Could you show us any code about the 'Lent' bit?
|
I PM'ed the code