Remove player from vehicle if not his - 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: Remove player from vehicle if not his (
/showthread.php?tid=298383)
Remove player from vehicle if not his -
HondaCBR - 20.11.2011
I'm using vehicle system, when you buy a vehicle it creates a file with your name, what do i have to add to this script below so that it checks if this is your vehicle and if not it removes you?
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
new file[256], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),"Cars/%s.ini",name);
if(dini_Exists(file))
{
return 1;
}
return 0;
}
Re: Remove player from vehicle if not his -
sleepysnowflake - 20.11.2011
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
new file[256], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),"Cars/%s.ini",name);
if(dini_Exists(file))
{
return 1;
}
else return RemovePlayerFromVehicle(playerid);
return 0;
}
-
HondaCBR - 20.11.2011
I thought this could work but I get an error
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
new file[256], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),"Cars/%s.ini",name);
if(dini_Exists(file))
{
new owner[24];
new veh = GetPlayerVehicleID(playerid);
GetPlayerName(OwnerID[veh], owner, sizeof(owner));
if(owner == name)
{
SendClientMessage(playerid, COLOR_ORANGE, "Just to test this script (THIS IS YOUR CAR).");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_ORANGE, "Just to test this script (NOT YOUR CAR).");
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}
2nd part i want something that will check for this:
JOE enters PAUL's car so it checks in PAUL file for KeyName=JOE and if it exists it allows him to stay, otherwise it removesplayer.
Re: Remove player from vehicle if not his -
MP2 - 20.11.2011
You need to use strcmp() to compare strings; they aren't the same as variables.
Re: Remove player from vehicle if not his -
HondaCBR - 20.11.2011
could you write that line for me
Re: Remove player from vehicle if not his -
HondaCBR - 20.11.2011
how can i write that line then so when if(name == owner) ....