class and vip allowed to use these vehicles...
#1

hey so i have this code but it does not work vip still get's locked out of vehicle....
Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
	new model = GetVehicleModel(vehicleid);

	if(model == 425 && Player[playerid][class] != AIRFORCE || Player[playerid][viplevel] < 1 || model == 520 && Player[playerid][class] != AIRFORCE && Player[playerid][viplevel] < 1) {
	
		ClearAnimations(playerid);
		SendClientMessage(playerid, C_RED, "• You need the class Airforce to fly this vehicle(or V.I.P)!");
		return 1;
	}

	if(model == 432 && Player[playerid][class] != HEAVY_GUNNER || Player[playerid][viplevel] < 1) {
	
	    ClearAnimations(playerid);
		SendClientMessage(playerid, C_RED, "• You need the class Heavy Gunner drive this vehicle!(or V.I.P)");
		return 1;
	}
	
	if(model == 416 && Player[playerid][class] != MEDIC || Player[playerid][viplevel] < 1) {

	    ClearAnimations(playerid);
		SendClientMessage(playerid, C_RED, "• You need the class Medic drive this vehicle!(or V.I.P)");
		return 1;
	}
	return 1;
}
thanks...
Reply
#2

You are using a incorrect control structure which is "<" and means "smaller then". In this case you are checking if the player has a vip level less then 1 and then execute the code, what you want to do is check if hes higher or equal to one.
pawn Код:
Player[playerid][viplevel] >= 1)
Take a look here: https://sampwiki.blast.hk/wiki/Control_Structures
Good luck!

edit: I think I made a mistake, you are checking if hes less then one, you can simply change "<" to "== 0" but the above code will work aswell if you change your code a bit.
Reply
#3

Quote:
Originally Posted by Voxel
Посмотреть сообщение
You are using a incorrect control structure which is "<" and means "smaller then". In this case you are checking if the player has a vip level less then 1 and then execute the code, what you want to do is check if hes higher or equal to one.
pawn Код:
Player[playerid][viplevel] >= 1)
Take a look here: https://sampwiki.blast.hk/wiki/Control_Structures
Good luck!

edit: I think I made a mistake, you are checking if hes less then one, you can simply change "<" to "== 0" but the above code will work aswell if you change your code a bit.
Yeah true, but I got question for my future scripting... Do I even need to say that you do not need a vip, I think do you need to check every time on play enter car is he vip, or I dont need to.
Reply
#4

Quote:
Originally Posted by xZdadyZx
Посмотреть сообщение
Yeah true, but I got question for my future scripting... Do I even need to say that you do not need a vip, I think do you need to check every time on play enter car is he vip, or I dont need to.
If you do not have a feature or something like that for vips then you obviously dont have to check for it. Like if you would have a feature that vips get a tuned car everytime they enter a vehicle then you would have to check if they are vips or not.

Hope that helped you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)