OnPlayerEnterVehicle
#1

I made code that other gang can't use the cars of VIP gang, but I have a problem. When another gang enter in the VIP vehicle, you can drive.
GameModeInit:
Код:
amxxbg[1] = AddStaticVehicle(409,1244.3000500,-2018.3000500,59.9000000,180.0000000,18,245); //Stretch
etc.
OnPlayerEnterVehicle:
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
        if(GetPlayerVehicleID(playerid) == amxxbg[1] || GetPlayerVehicleID(playerid) == amxxbg[2] || GetPlayerVehicleID(playerid) == amxxbg[3] || GetPlayerVehicleID(playerid) == amxxbg[4] || GetPlayerVehicleID(playerid) == amxxbg[5] || GetPlayerVehicleID(playerid) == amxxbg[6] || GetPlayerVehicleID(playerid) == amxxbg[7] || GetPlayerVehicleID(playerid) == amxxbg[8] || GetPlayerVehicleID(playerid) == amxxbg[9] || GetPlayerVehicleID(playerid) == amxxbg[10] || GetPlayerVehicleID(playerid) == amxxbg[11] ||
        GetPlayerVehicleID(playerid) == amxxbg[12] || GetPlayerVehicleID(playerid) == amxxbg[13] || GetPlayerVehicleID(playerid) == amxxbg[14] || GetPlayerVehicleID(playerid) == amxxbg[15] || GetPlayerVehicleID(playerid) == amxxbg[16] || GetPlayerVehicleID(playerid) == amxxbg[17] || GetPlayerVehicleID(playerid) == amxxbg[18] || GetPlayerVehicleID(playerid) == amxxbg[19] || GetPlayerVehicleID(playerid) == amxxbg[20] || GetPlayerVehicleID(playerid) == amxxbg[21] || 						GetPlayerVehicleID(playerid) == amxxbg[22] ||
        GetPlayerVehicleID(playerid) == amxxbg[23] || GetPlayerVehicleID(playerid) == amxxbg[24])
	{
	 	if(PlayerInfo[playerid][pMember] != TEAM_VIP)
	   	{
	      	        new Float:shealth;
			new Float:slx, Float:sly, Float:slz;
			GetPlayerHealth(playerid, shealth);
			SetPlayerHealth(playerid, shealth-5);
			GetPlayerPos(playerid, slx, sly, slz);
			SetPlayerPos(playerid, slx+2, sly, slz);
			PlayerPlaySound(playerid, 1130, slx, sly, slz+5);
			SendClientMessage(playerid, -1, "{808080}You can't drive VIP Gang vehicles");
		}
	}
        return 1;
}
Please help
Reply
#2

Try this:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
        if(GetPlayerVehicleID(playerid) == amxxbg[1] || GetPlayerVehicleID(playerid) == amxxbg[2] || GetPlayerVehicleID(playerid) == amxxbg[3] || GetPlayerVehicleID(playerid) == amxxbg[4] || GetPlayerVehicleID(playerid) == amxxbg[5] || GetPlayerVehicleID(playerid) == amxxbg[6] || GetPlayerVehicleID(playerid) == amxxbg[7] || GetPlayerVehicleID(playerid) == amxxbg[8] || GetPlayerVehicleID(playerid) == amxxbg[9] || GetPlayerVehicleID(playerid) == amxxbg[10] || GetPlayerVehicleID(playerid) == amxxbg[11] ||
        GetPlayerVehicleID(playerid) == amxxbg[12] || GetPlayerVehicleID(playerid) == amxxbg[13] || GetPlayerVehicleID(playerid) == amxxbg[14] || GetPlayerVehicleID(playerid) == amxxbg[15] || GetPlayerVehicleID(playerid) == amxxbg[16] || GetPlayerVehicleID(playerid) == amxxbg[17] || GetPlayerVehicleID(playerid) == amxxbg[18] || GetPlayerVehicleID(playerid) == amxxbg[19] || GetPlayerVehicleID(playerid) == amxxbg[20] || GetPlayerVehicleID(playerid) == amxxbg[21] ||                         GetPlayerVehicleID(playerid) == amxxbg[22] ||
        GetPlayerVehicleID(playerid) == amxxbg[23] || GetPlayerVehicleID(playerid) == amxxbg[24])
        {
            if(PlayerInfo[playerid][pMember] != TEAM_VIP)
            {
                ClearAnimations(playerid,1);
                new Float:shealth;
                new Float:slx, Float:sly, Float:slz;
                GetPlayerHealth(playerid, shealth);
                SetPlayerHealth(playerid, shealth-5);
                GetPlayerPos(playerid, slx, sly, slz);
                SetPlayerPos(playerid, slx+2, sly, slz);
                PlayerPlaySound(playerid, 1130, slx, sly, slz+5);
                SendClientMessage(playerid, -1, "{808080}You can't drive VIP Gang vehicles");
            }
        }
        return 1;
}
Reply
#3

pawn Код:
bool:IsVipVehicle(vehicleid)
{

    for(new i=0; i != sizeof(amxxbg); i++)
        if(vehicleid == amxxbg[i])
            return true;

    return false;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(IsVipVehicle(vehicleid))
    {
        if(PlayerInfo[playerid][pMember] != TEAM_VIP)
        {
            new Float:shealth;
            new Float:slx, Float:sly, Float:slz;
            GetPlayerHealth(playerid, shealth);
            SetPlayerHealth(playerid, shealth-5);
            GetPlayerPos(playerid, slx, sly, slz);
            SetPlayerPos(playerid, slx+2, sly, slz);
            PlayerPlaySound(playerid, 1130, slx, sly, slz+5);
            SendClientMessage(playerid, -1, "{808080}You can't drive VIP Gang vehicles");
        }
    }
    return 1;
}
EDIT

Use zPain code is better
Reply
#4

Try it:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
        if(vehicleid >= amxxbg[1] && vehicleid <= amxxbg[24])
        {
            if(PlayerInfo[playerid][pMember] != TEAM_VIP)
            {
                ClearAnimations(playerid,1);
                new Float:shealth;
                new Float:slx, Float:sly, Float:slz;
                GetPlayerHealth(playerid, shealth);
                SetPlayerHealth(playerid, shealth-5);
                GetPlayerPos(playerid, slx, sly, slz);
                SetPlayerPos(playerid, slx+2, sly, slz);
                PlayerPlaySound(playerid, 1130, slx, sly, slz+5);
                SendClientMessage(playerid, -1, "{808080}You can't drive VIP Gang vehicles");
            }
        }
        return 1;
}
Reply
#5

Quote:
Originally Posted by zPain
Посмотреть сообщение
Try it:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
        if(vehicleid >= amxxbg[1] && vehicleid <= amxxbg[24])
        {
            if(PlayerInfo[playerid][pMember] != TEAM_VIP)
            {
                ClearAnimations(playerid,1);
                new Float:shealth;
                new Float:slx, Float:sly, Float:slz;
                GetPlayerHealth(playerid, shealth);
                SetPlayerHealth(playerid, shealth-5);
                GetPlayerPos(playerid, slx, sly, slz);
                SetPlayerPos(playerid, slx+2, sly, slz);
                PlayerPlaySound(playerid, 1130, slx, sly, slz+5);
                SendClientMessage(playerid, -1, "{808080}You can't drive VIP Gang vehicles");
            }
        }
        return 1;
}
Thank you very much!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)