CMD:bl(playerid, params[]) { new vID = GetPlayerVehicleID(playerid); if(eingeloggt[playerid] == 0)return SendClientMessage(playerid,COLOR_RED,"Du bist noch nicht eingeloggt."); if(pTazed[playerid] == 1)return SendClientMessage(playerid,COLOR_RED,"Du bist getazed."); if(pInfo[playerid][fraktion] != 1)return SendClientMessage(playerid,COLOR_RED,"Du bist kein Mitglied vom SFPD."); if(pInfo[playerid][fraktion] == 1 && pInfo[playerid][duty] != 1)return SendClientMessage(playerid,COLOR_RED,"Du bist nicht im Dienst."); if(GetPVarInt(playerid,"SireneAn") == 1) { DestroyObject(blaulicht[playerid]); DestroyObject(blaulicht2[playerid]); DestroyObject(blaulicht3[playerid]); GameTextForPlayer(playerid,"~r~Blaulicht Deaktiviert",2000,3); SetPVarInt(playerid,"SireneAn",0); return 1; } if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,COLOR_RED,"Du sitzt in keinem Fahrzeug."); if(!IsAPoliceVehicle(vID))return SendClientMessage(playerid,COLOR_RED,"Du sitzt in keinem PD Fahrzeug."); if(GetVehicleModel(vID) != 426 | 560)return SendClientMessage(playerid,COLOR_RED,"Du sitzt in keinem PD Premier/Sultan/Cheetah/Securicar"); if(GetVehicleModel(vID) == 426) { if(GetPVarInt(playerid,"SireneAn") == 1) { DestroyObject(blaulicht[playerid]); DestroyObject(blaulicht2[playerid]); DestroyObject(blaulicht3[playerid]); GameTextForPlayer(playerid,"~r~Blaulicht Deaktiviert",2000,3); SetPVarInt(playerid,"SireneAn",0); return 1; } DestroyObject(blaulicht[playerid]); new Float:x,Float:y,Float:z; GetPlayerPos(playerid,x,y,z); blaulicht[playerid] = CreateObject(19797,0.0,0.0,0.0,0.0,0.0,0.0); blaulicht2[playerid] = CreateObject(19797,0.0,0.0,0.0,0.0,0.0,0.0); blaulicht3[playerid] = CreateObject(19797,0.0,0.0,0.0,0.0,0.0,0.0); AttachObjectToVehicle(blaulicht[playerid],vID,0.0,0.35,0.65,0.0,0.0,180.0); AttachObjectToVehicle(blaulicht2[playerid],vID,0.5,-1.35,0.40,0.0,0.0,0.0); AttachObjectToVehicle(blaulicht3[playerid],vID,-0.5,-1.35,0.40,0.0,180.0,0.0); GameTextForPlayer(playerid,"~g~Blaulicht Aktiviert",2000,3); SetPVarInt(playerid,"SireneAn",1); return 1; } if(GetVehicleModel(vID) == 560) { if(GetPVarInt(playerid,"SireneAn") == 1) { DestroyObject(blaulicht[playerid]); DestroyObject(blaulicht2[playerid]); DestroyObject(blaulicht3[playerid]); GameTextForPlayer(playerid,"~r~Blaulicht Deaktiviert",2000,3); SetPVarInt(playerid,"SireneAn",0); return 1; } DestroyObject(blaulicht[playerid]); new Float:x,Float:y,Float:z; GetPlayerPos(playerid,x,y,z); blaulicht[playerid] = CreateObject(19797,0.0,0.0,0.0,0.0,0.0,0.0); blaulicht2[playerid] = CreateObject(19797,0.0,0.0,0.0,0.0,0.0,0.0); blaulicht3[playerid] = CreateObject(19797,0.0,0.0,0.0,0.0,0.0,0.0); AttachObjectToVehicle(blaulicht[playerid],vID,0.0,0.35,0.65,0.0,0.0,180.0); AttachObjectToVehicle(blaulicht2[playerid],vID,0.5,-1.35,0.40,0.0,0.0,0.0); AttachObjectToVehicle(blaulicht3[playerid],vID,-0.5,-1.35,0.40,0.0,180.0,0.0); GameTextForPlayer(playerid,"~g~Blaulicht Aktiviert",2000,3); SetPVarInt(playerid,"SireneAn",1); } return 1; }
if(GetVehicleModel(vID) != 426 | 560)return SendClientMessage(playerid,COLOR_RED,"Du sitzt in keinem PD Premier/Sultan/Cheetah/Securicar");
if(GetVehicleModel(vID) != 426 || 560)return SendClientMessage(playerid,COLOR_RED,"Du sitzt in keinem PD Premier/Sultan/Cheetah/Securicar");
please replace | with ||
pawn Код:
|
please replace | with ||
pawn Код:
|
new a = 426, b = 560;
if(GetVehicleModel(vID) a == 426 && b != 426)return SendClientMessage(playerid,COLOR_RED,"Du sitzt in keinem PD Premier/Sultan/Cheetah/Securicar");
new DoCSkins[] = { 70, 71, 74, 280, 281, 282, 288, 284, 285, 283, 265, 266, 267, 274, 275, 276, 277, 278, 300, 301, 302, 306, 307, 308, 309, 310, 311, 279 }; ... stock IsDoCSkin(id) { for(new i = 0; i < sizeof(DoCSkins); i++) { if(id == DoCSkins[i]) return 1; } return 0; }
if(IsDoCSkin(modelid)) { //Do your actions here }
There's a simple way to deal with it. You can create an array of siren-only vehicles and check if it is in the list.
On my server, I used to check whether some skin I chose is faction only. That's how it looked like: Код:
new DoCSkins[] = { 70, 71, 74, 280, 281, 282, 288, 284, 285, 283, 265, 266, 267, 274, 275, 276, 277, 278, 300, 301, 302, 306, 307, 308, 309, 310, 311, 279 }; ... stock IsDoCSkin(id) { for(new i = 0; i < sizeof(DoCSkins); i++) { if(id == DoCSkins[i]) return 1; } return 0; } Код:
if(IsDoCSkin(modelid)) { //Do your actions here } P.S. This array is defined globally, don't initialise it in some functions or whatever. P.P.S. imo this approach is comfortable since it simply requires you to add newly picked vehicles/skins/whatever you use it with into the array to then do the same check which requires no changes in its code. |
IsAUndercoverVehicle(vehicleid) { new vModel = GetVehicleModel(vehicleid); for(new i = 0; i < sizeof(UCAutos); i++) { if(vModel == UCAutos[i]) return true; } return false; }
if(!IsAUndercoverVehicle(vID))return SendClientMessage(playerid,COLOR_RED,"Du sitzt in keinem PD Premier/Sultan/Cheetah/Securicar");
new UCAutos[] = { 428, 415, 560, 426 };