Help - 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: Help (
/showthread.php?tid=288277)
Help -
Salsa - 07.10.2011
Player Not Removing From Vechile Its Says This car is not yours
and player can take private vechile ?
Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
if(vehicleid == FireCat)//Checking if the vehicleid matches the FireCat one.
{
new name[MAX_PLAYER_NAME];//Where we will store the players name in a 24 size.
GetPlayerName(playerid,name,MAX_PLAYER_NAME);//Getting the players name and storing it in pName.
if(strcmp(name,"KAPIL") == 0)//String compare between the users name and the selected name.
{
//If the 2 names are the same...
SendClientMessage(playerid,-1,"Welcome to your car!");
}
else//Else if the 2 names don't match....
{
RemovePlayerFromVehicle(playerid);//Lets remove him from the vehicle
SendClientMessage(playerid,-1,"This car is not yours!");
}
}
return 1;
}
Re: Help -
Haydz - 07.10.2011
You can't remove a player from a vehicle when they are entering it, they arn't in the vehicle yet. Use OnPlayerStateChange instead
Re: Help -
Backwardsman97 - 07.10.2011
I think it's because you need to return 0 if they aren't the specified player. You can't use RemovePlayerFromVehicle in OnPlayerEnterVehicle because it gets called as soon as they press enter. So they aren't actually in a vehicle when it gets called. I would suggest OnPlayerStateChange. Try this.
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
if(GetPlayerVehicleID(playerid) == FireCat)//Checking if the vehicleid matches the FireCat one.
{
new name[MAX_PLAYER_NAME];//Where we will store the players name in a 24 size.
GetPlayerName(playerid,name,MAX_PLAYER_NAME);//Getting the players name and storing it in pName.
if(strcmp(name,"KAPIL") == 0)//String compare between the users name and the selected name.
{
//If the 2 names are the same...
SendClientMessage(playerid,-1,"Welcome to your car!");
}
else//Else if the 2 names don't match....
{
RemovePlayerFromVehicle(playerid);//Lets remove him from the vehicle
SendClientMessage(playerid,-1,"This car is not yours!");
}
return 1;
}
}
return 1;
}
Re: Help -
Salsa - 07.10.2011
WTF: Backwardsman97 You Are genus Its Working O wOw Thanks
Res Added:
Re: Help -
Salsa - 07.10.2011
can i add more privates cars if yes how
Re: Help -
Backwardsman97 - 07.10.2011
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new
v = GetPlayerVehicleID(playerid);
if(v == FireCat)//Checking if the vehicleid matches the FireCat one.
{
new name[MAX_PLAYER_NAME];//Where we will store the players name in a 24 size.
GetPlayerName(playerid,name,MAX_PLAYER_NAME);//Getting the players name and storing it in pName.
if(strcmp(name,"KAPIL") == 0)//String compare between the users name and the selected name.
{
//If the 2 names are the same...
SendClientMessage(playerid,-1,"Welcome to your car!");
}
else//Else if the 2 names don't match....
{
RemovePlayerFromVehicle(playerid);//Lets remove him from the vehicle
SendClientMessage(playerid,-1,"This car is not yours!");
}
return 1;
}
if(v == OtherCat)//Checking if the vehicleid matches the FireCat one.
{
return 1;
}
}
return 1;
}
Like So.
Re: Help -
Salsa - 07.10.2011
oops with this players not removing from car >
Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new
v = GetPlayerVehicleID(playerid);
if(v == FireCat)//Checking if the vehicleid matches the FireCat one.
{
new name[MAX_PLAYER_NAME];//Where we will store the players name in a 24 size.
GetPlayerName(playerid,name,MAX_PLAYER_NAME);//Getting the players name and storing it in pName.
if(strcmp(name,"KAPIL") == 0)//String compare between the users name and the selected name.
{
//If the 2 names are the same...
SendClientMessage(playerid,-1,"Welcome to your car!");
}
else//Else if the 2 names don't match....
{
RemovePlayerFromVehicle(playerid);//Lets remove him from the vehicle
SendClientMessage(playerid,-1,"This car is not yours!");
}
return 1;
}
if(v == OtherCat)//Checking if the vehicleid matches the FireCat one.
{
return 1;
}
}
return 1;
}
Re: Help -
Backwardsman97 - 07.10.2011
From the FireCat car?
Re: Help -
Salsa - 08.10.2011
yes ??