Quote:
Originally Posted by Eoussama
so it would be something like this?
PHP код:
new VehID = GetPlayerVehicleID(playerid);
if(newstate == PLAYER_STATE_DRIVER && (VehID, gVIPVehicles[37])){
if(VIPInfo[playerid][VIPLevel] > 0){
SendClientMessage(playerid, YELLOW, "[VIP]: Welcome to VIP Vehicle");
return 1;
}
else{
ErrorMessages(playerid, 1);
RemovePlayerFromVehicle(playerid);
}
}
because it didn't work, the client message didn't showup neither ways
|
No. By entering the literal 37, you specifically specify that the message should only show when being the driver of the 38th vehicle.
PHP код:
IsVIPVehicle(vehicleid) {
for(new i, j = sizeof(gVIPVehicles); i < j; i++) {
if(vehicleid == gVIPVehicles[i]) {
return true;
}
}
return false;
}
You loop through all the VIP vehicles and check whether the vehicleid returned by GetPlayerVehicleID is equal to any of them. If so: return true, else: return false.
PHP код:
if(newstate == PLAYER_STATE_DRIVER && IsVIPVehicle(VehID)) {
// Code for when the player is in a VIP vehicle
}
The return value of IsVIPVehicle is then used in the if statement. The
&& requires both
newstate == PLAYER_STATE_DRIVER and
IsVIPVehicle(VehID) to be true before executing the code in the if's body.