SA-MP Forums Archive
Help again please xD Sorry.. XD - 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: Help again please xD Sorry.. XD (/showthread.php?tid=159596)



Help again please xD Sorry.. XD - bartje01 - 13.07.2010

well guys, I'm sorry to say this, but I really need help again.
I want that a normal player can't join a cop car as a driver. As a passenger he is allowed.

I know have this:
But even as a driver a non cop can still get in:O
please help:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

    if(GetPlayerVehicleID(playerid) == 497||596||597||598||599)
    {
    if(sapd[playerid]<=0)
    {
    RemovePlayerFromVehicle(playerid);
    SendClientMessage(playerid,COLOR_RED,"You are not part of the Sanandreas Police Department.");
    SendClientMessage(playerid,COLOR_RED,"The police has spotted you on the security camera. Get away before you get arrested!");
    }
    }
    return 1;
}



Re: Help again please xD Sorry.. XD - Zezombia - 13.07.2010

First off:
pawn Код:
if(GetPlayerVehicleID(playerid) == 497||596||597||598||599)
That would not work. It would have to be:
pawn Код:
if(GetPlayerVehicleID(playerid) == 497 || GetPlayerVehicleID(playerid) == 596 || /*etc*/)
To check if a player is a passenger, you would use:
pawn Код:
if(ispassenger == 1)



Re: Help again please xD Sorry.. XD - Fj0rtizFredde - 13.07.2010

Are you also sure that you mean VehicleID and not ModelID?


Re: Help again please xD Sorry.. XD - Zezombia - 13.07.2010

Fj0rtizFredde has a great point, if your trying to get the modelid then you would use:
pawn Код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 497 || /*etc*/)
Or you can make a define to save a lot of room:
pawn Код:
#define v GetVehicleModel(GetPlayerVehicleID(playerid))
if(v == 497 || v == 596 || /*etc*/)



Re: Help again please xD Sorry.. XD - TouR - 13.07.2010

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

    if((GetVehicleModel(GetPlayerVehicleID(playerid)) == 497 || (GetVehicleModel(GetPlayerVehicleID(playerid)) == 596||(GetVehicleModel(GetPlayerVehicleID(playerid)) == 597 ||(GetVehicleModel(GetPlayerVehicleID(playerid)) == 598 ||(GetVehicleModel(GetPlayerVehicleID(playerid)) == 599)
    {
    if(sapd[playerid]<=0)
    {
    new Float:pX,Float:pY,Float:pZ
    GetPlayerPos(playerid,pX,pY,pZ);
    SetPlayerPos(playerid,pX,pY,pZ);
    SendClientMessage(playerid,COLOR_RED,"You are not part of the Sanandreas Police Department.");
    SendClientMessage(playerid,COLOR_RED,"The police has spotted you on the security camera. Get away before you get arrested!");
    }
    }
    return 1;
}


Re: Help again please xD Sorry.. XD - bartje01 - 13.07.2010

First of all, I think I failed. I indeed mean model.
Second of all:
Doesn't work :O
I still can join whitout being a cop

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

    if(GetVehicleModel(playerid) == 497 || GetVehicleModel(playerid) == 596 ||GetVehicleModel(playerid) == 597 ||GetVehicleModel(playerid) == 598 ||GetVehicleModel(playerid) == 599)
    {
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
 {
    if(sapd[playerid]==0)
    {
    RemovePlayerFromVehicle(playerid);
    SendClientMessage(playerid,COLOR_RED,"You are not part of the Sanandreas Police Department.");
    SendClientMessage(playerid,COLOR_RED,"The police has spotted you on the security camera. Get away before you get arrested!");
    }
    }
    }
    return 1;
}



Re: Help again please xD Sorry.. XD - TouR - 13.07.2010

Use the code i gave you


Re: Help again please xD Sorry.. XD - bartje01 - 13.07.2010

Your code hates me xD
5 errors:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

if((GetVehicleModel(GetPlayerVehicleID(playerid)) == 497 || (GetVehicleModel(GetPlayerVehicleID(playerid)) == 596||(GetVehicleModel(GetPlayerVehicleID(playerid)) == 597 ||(GetVehicleModel(GetPlayerVehicleID(playerid)) == 598 ||(GetVehicleModel(GetPlayerVehicleID(playerid)) == 599)
    {   //488
    if(sapd[playerid]<=0) //489
    {
    new Float:pX,Float:pY,Float:pZ
    GetPlayerPos(playerid,pX,pY,pZ);
    SetPlayerPos(playerid,pX,pY,pZ);
    SendClientMessage(playerid,COLOR_RED,"You are not part of the Sanandreas Police Department.");
    SendClientMessage(playerid,COLOR_RED,"The police has spotted you on the security camera. Get away before you get arrested!");

    }
    }
    }
    return 1;
}



Re: Help again please xD Sorry.. XD - TouR - 13.07.2010

show me the errors?


Re: Help again please xD Sorry.. XD - coole210 - 14.07.2010

Quote:
Originally Posted by tour15
Посмотреть сообщение
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{

    if((GetVehicleModel(GetPlayerVehicleID(playerid)) == 497 || (GetVehicleModel(GetPlayerVehicleID(playerid)) == 596||(GetVehicleModel(GetPlayerVehicleID(playerid)) == 597 ||(GetVehicleModel(GetPlayerVehicleID(playerid)) == 598 ||(GetVehicleModel(GetPlayerVehicleID(playerid)) == 599)
    {
    if(sapd[playerid]<=0)
    {
    new Float:pX,Float:pY,Float:pZ
    GetPlayerPos(playerid,pX,pY,pZ);
    SetPlayerPos(playerid,pX,pY,pZ);
    SendClientMessage(playerid,COLOR_RED,"You are not part of the Sanandreas Police Department.");
    SendClientMessage(playerid,COLOR_RED,"The police has spotted you on the security camera. Get away before you get arrested!");
    }
    }
    return 1;
}
That looks alot like the locking system i use in my old server (TPG RPG)

:S