Car Syst Bug - 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: Car Syst Bug (
/showthread.php?tid=548408)
Car Syst Bug -
DovIIs - 29.11.2014
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.
Re: Car Syst Bug -
DovIIs - 29.11.2014
BUMP
Re: Car Syst Bug -
DovIIs - 29.11.2014
BUMP
Re: Car Syst Bug -
PowerPC603 - 29.11.2014
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.
Re: Car Syst Bug -
DovIIs - 30.11.2014
Thank you for ur replay

I will chechk it later