Help again please xD Sorry.. XD
#1

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;
}
Reply
#2

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)
Reply
#3

Are you also sure that you mean VehicleID and not ModelID?
Reply
#4

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*/)
Reply
#5

Код:
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;
}
Reply
#6

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;
}
Reply
#7

Use the code i gave you
Reply
#8

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;
}
Reply
#9

show me the errors?
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)