Beitrag von hackedicht ()
Dieser Beitrag wurde vom Autor gelöscht ().
Hast du denn Command mal gedebugt?
wenn ja ist die Fahrzeug ID und das Alles immer gleich?
Ich kapier nicht ganz was diese Zuordnung bedeutet:
sirene[vID]=0;
Also was ist sirene[vID]?
Dein Problem ist, dass die Variable Sirenean nur lokal ist, nicht global
Warum ist das ein Problem ? Er braucht die Variable nicht außerhalb des Befehls oder hab ich was überlesen ?
Ist ungetestet: Ich habe den befehl auf /sirene verkürzt.. es wird automatisch an und aus geschalten Sollte funktionieren
ocmd:sirene(playerid,params[])
{
new Float: vx,Float: vy, Float: vz;
new vID=GetPlayerVehicleID(playerid),cmd[5];
new sirene[MAX_VEHICLES];
new sirenestat[MAX_VEHICLES];
if(IsPlayerInAnyVehicle(playerid))
{
if(GetVehicleModel(vID)==560)
{
GetPlayerPos(playerid,vx,vy,vz);
if(sirenestat[vID] == 0)
{
sirene[vID]=CreateObject(18646,0,0,-1000,0,0,0,100);
AttachObjectToVehicle(sirene[vID],vID,0.450000,0.075000,0.749999,-10.799998,0.000000,0.000000);
sirenestat[vID]= 1;
SendClientMessage(playerid,BLAU,"Du hast die Einsatzsignalleuchte eingeschaltet.");
}
SendClientMessage(playerid,BLAU,"Du hast die Einsatzsignalleuchte ausgeschaltet.");
DestroyObject(sirene[vID]);
sirenestat[vID] = 0;
return 1;
}
if(GetVehicleModel(vID)==490)
{
if(sirenestat[vID] == 1)
{
SendClientMessage(playerid,BLAU,"Du hast die Einsatzsignalleuchte ausgeschaltet.");
DestroyObject(sirene[vID]);
sirenestat[vID]=0;
return 1;
}
else
{
sirene[vID]=CreateObject(18646,0,0,-1000,0,0,0,100);
AttachObjectToVehicle(sirene[vID],vID,-0.599999,1.125000,1.049999,-18.900001,0.000000,0.000000);
SendClientMessage(playerid,BLAU,"Du hast die Einsatzsignalleuchte eingeschaltet.");
sirenestat[vID] = 1;
return 1;
}
}
}
}
Und falls du fragen hast frag ruhig
new Sirene[MAX_VEHICES];
ocmd:sirene(playerid,params[])
{
new cmd[3];
if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,BLAU,"Du befindest dich nicht in einem Fahrzeug!");
if(sscanf(params,"s",cmd))return SendClientMessage(playerid,USEWHITE,"/sirene an/aus");
if(!strcmp(cmd,"an",true)){
if(GetVehicleModel(GetPlayerVehicleID(playerid))==560&&Sirene[GetPlayerVehicleID(playerid)]==0){
Sirene[GetPlayerVehicleID(playerid)]=CreateObject(18646,0,0,-1000,0,0,0,100);
AttachObjectToVehicle(sirene[vID],vID,0.450000,0.075000,0.749999,-10.799998,0.000000,0.000000);
return SendClientMessage(playerid,BLAU,"Du hast die Einsatzsignalleuchte eingeschaltet.");
}
else if(GetVehicleModel(GetPlayerVehicleID(playerid))==490&&Sirene[GetPlayerVehicleID(playerid]==0){
Sirene[GetPlayerVehicleID(playerid)]=CreateObject(18646,0,0,-1000,0,0,0,100);
AttachObjectToVehicle(sirene[vID],vID,-0.599999,1.125000,1.049999,-18.900001,0.000000,0.000000);
return SendClientMessage(playerid,BLAU,"Du hast die Einsatzsignalleuchte eingeschaltet.");
}
return 1;
}
else if(!strcmp(cmd,"aus",true)){
if(GetVehicleModel(GetPlayerVehicleID(playerid))==560||GetVehicleModel(GetPlayerVehicleID(playerid))==490&&Sirene[GetPlayerVehicleID(playerid]!=0){
DestroyObject(Sirene[GetPlayerVehicleID(playerid)]),SendClientMessage(playerid,BLAU,"Du hast die Einsatzsignalleuchte ausgeschaltet.");
return Sirene[GetPlayerVehicleID(playerid]=0;
}
}
return 1;
}
Probier das mal so aus, sollte klappen
//Globale Variablen
new UCL[MAX_VEHICLES];
new sirene[MAX_VEHICLES];
new sirene1[MAX_VEHICLES];
new sirene2[MAX_VEHICLES];
new sirene3[MAX_VEHICLES];
new sirene4[MAX_VEHICLES];
if(strcmp(cmdtext,"/sirene",true)==0)
{
if(UCL[GetPlayerVehicleID(playerid)] == 0)
{
new tmpcar = GetPlayerVehicleID(playerid);
if(GetVehicleModel(tmpcar) == 560)
{
sirene[GetPlayerVehicleID(playerid)] = CreateObject(19288,0,0,0,0,0,0,100);
sirene1[GetPlayerVehicleID(playerid)] = CreateObject(18646,0,0,0,0,0,0,100);
sirene2[GetPlayerVehicleID(playerid)] = CreateObject(19288,0,0,0,0,0,0,100);
sirene3[GetPlayerVehicleID(playerid)] = CreateObject(19288,0,0,0,0,0,0,100);
sirene4[GetPlayerVehicleID(playerid)] = CreateObject(19292,0,0,0,0,0,0,100);
AttachObjectToVehicle(sirene[GetPlayerVehicleID(playerid)],GetPlayerVehicleID(playerid),0 ,2.6,0,0,0,0);//Vorne Mitte
AttachObjectToVehicle(sirene1[GetPlayerVehicleID(playerid)],GetPlayerVehicleID(playerid),-0.5,0.0,0.85,0,0,0);//Dach sirene
AttachObjectToVehicle(sirene2[GetPlayerVehicleID(playerid)],GetPlayerVehicleID(playerid),0.7,2.6,0,0,0,0);//Vorne Licht Beifahrerseite
AttachObjectToVehicle(sirene3[GetPlayerVehicleID(playerid)],GetPlayerVehicleID(playerid),-0.7,2.6,0,0,0,0);//Vorne Licht Fahrerseite
AttachObjectToVehicle(sirene4[GetPlayerVehicleID(playerid)],GetPlayerVehicleID(playerid),0,0.9,0.4,0,0,0);//Mittig im Fenster
UCL[GetPlayerVehicleID(playerid)] = 1;
return 1;
}
}
else if(UCL[GetPlayerVehicleID(playerid)] == 1)
{
DestroyObject(sirene[GetPlayerVehicleID(playerid)]);
DestroyObject(sirene1[GetPlayerVehicleID(playerid)]);
DestroyObject(sirene2[GetPlayerVehicleID(playerid)]);
DestroyObject(sirene3[GetPlayerVehicleID(playerid)]);
DestroyObject(sirene4[GetPlayerVehicleID(playerid)]);
UCL[GetPlayerVehicleID(playerid)] = 0;
return 1;
}
}
return 1;
}
ocmd:sirene(playerid,params[])
{
new vID=GetPlayerVehicleID(playerid);
new sirene = CreateObject(18646,0,0,-1000,0,0,0,100);
new sirenestat[MAX_VEHICLES];
if(IsPlayerInAnyVehicle(playerid))
{
if(GetVehicleModel(vID) == 560 || GetVehicleModel(vID) == 490)
{
if(sirenestat[vID] == 0)
{
AttachObjectToVehicle(18646,vID,0.450000,0.075000,0.749999,-10.799998,0.000000,0.000000);
sirenestat[vID]= 1;
SendClientMessage(playerid,BLAU,"Du hast die Einsatzsignalleuchte eingeschaltet.");
}
else
{
SendClientMessage(playerid,BLAU,"Du hast die Einsatzsignalleuchte ausgeschaltet.");
DestroyObject(sirene);
sirenestat[vID] = 0;
return 1;
}
}
}
return 1;
}
probiers mal
new Sirene[MAX_VEHICLES];
ocmd:sirene(playerid,params[])
{
new cmd[4];
if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,orange,"Du befindest dich nicht in einem Fahrzeug!");
if(sscanf(params,"s[4]",cmd))return SendClientMessage(playerid,weis,"/sirene an/aus");
if(!strcmp(cmd,"an",true)){
if(GetVehicleModel(GetPlayerVehicleID(playerid))==560&&Sirene[GetPlayerVehicleID(playerid)]==0){
Sirene[GetPlayerVehicleID(playerid)]=CreateObject(18646,0,0,-1000,0,0,0,100);
AttachObjectToVehicle(Sirene[GetPlayerVehicleID(playerid)],GetPlayerVehicleID(playerid),0.450000,0.075000,0.749999,-10.799998,0.000000,0.000000);
return SendClientMessage(playerid,orange,"Du hast die Einsatzsignalleuchte eingeschaltet.");
}
else if(GetVehicleModel(GetPlayerVehicleID(playerid))==490&&Sirene[GetPlayerVehicleID(playerid)]==0){
Sirene[GetPlayerVehicleID(playerid)]=CreateObject(18646,0,0,-1000,0,0,0,100);
AttachObjectToVehicle(Sirene[GetPlayerVehicleID(playerid)],GetPlayerVehicleID(playerid),-0.599999,1.125000,1.049999,-18.900001,0.000000,0.000000);
return SendClientMessage(playerid,orange,"Du hast die Einsatzsignalleuchte eingeschaltet.");
}
}
else if(!strcmp(cmd,"aus",true)){
if(GetVehicleModel(GetPlayerVehicleID(playerid))==560||GetVehicleModel(GetPlayerVehicleID(playerid))==490&&Sirene[GetPlayerVehicleID(playerid)]!=0){
DestroyObject(Sirene[GetPlayerVehicleID(playerid)]);
SendClientMessage(playerid,orange,"Du hast die Einsatzsignalleuchte ausgeschaltet.");
return Sirene[GetPlayerVehicleID(playerid)]=0,1;
}
}
return 1;
}
Von meinerseits waren dort einige Fehler drin, die ich nun behoben habe.
Der Befehl wurde von mir getestet und funktioniert einwandfrei