/news Befehl bugg

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Hey,


    wieso kann ich den /news Befehl nur in einem einzigen Car benutzen statt in alles NewsCar's?


    Code:

    Spoiler anzeigen
    ocmd:news(playerid,params[])
    {
    if(PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pLeader] == 4)
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    for(new i=0; i<sizeof(NewsCar); i++)
    {
    if(GetPlayerVehicleID(playerid) == NewsCar[i])
    {
    new text[128],nr[128];
    if(sscanf(params,"s",text)) return SendClientMessage(playerid,Grau,"[Benutze]: /news [Text]");
    format(nr,sizeof(nr),"NR %s: %s",GetName(playerid),text);
    SendClientMessageToAll(Orange,nr);
    return 1;
    }
    Fehler(playerid,"Du bist in keinem News Fahrzeug!");
    return 1;
    }
    }
    Fehler(playerid,"Du bist in keinem News Fahrzeug!");
    return 1;
    }
    Fehler(playerid,"Du bist kein News Reporter!");
    return 1;
    }


    Vehicles:

    Spoiler anzeigen
    //NEWS REPORTER
    NewsCar[0]=AddStaticVehicle(582,-314.7514,1515.3643,75.4135,0.0,0,0); // newsVan
    NewsCar[1]=AddStaticVehicle(582,-317.8429,1515.3643,75.4135,0.0,0,0); // newsVan
    NewsCar[2]=AddStaticVehicle(582,-320.9344,1515.3643,75.4135,0.0,0,0); // newsVan
    NewsCar[3]=AddStaticVehicle(582,-324.0259,1515.3643,75.4135,0.0,0,0); // newsVan
    NewsCar[4]=AddStaticVehicle(582,-327.1174,1515.3643,75.4135,0.0,0,0); // newsVan
    NewsCar[5]=AddStaticVehicle(582,-330.2089,1515.3643,75.4135,0.0,0,0); // newsVan
    NewsCar[6]=AddStaticVehicle(582,-333.3004,1515.3643,75.4135,0.0,0,0); // newsVan
    NewsCar[7]=AddStaticVehicle(582,-336.3919,1515.3643,75.4135,0.0,0,0); // newsVan
    NewsCar[8]=AddStaticVehicle(582,-339.4834,1515.3643,75.4135,0.0,0,0); // newsVan
    NewsCar[9]=AddStaticVehicle(582,-342.5749,1515.3643,75.4135,0.0,0,0); // newsVan
    NewsCar[10]=AddStaticVehicle(582,-345.6664,1515.3643,75.4135,0.0,0,0); // newsVan
    NewsCar[11]=AddStaticVehicle(488,-309.9134,1569.4065,75.5367,275.5628,0,0); // Heli
    NewsCar[12]=AddStaticVehicle(488,-302.1933,1561.5715,75.5366,277.8422,0,0); // Heli
    NewsCar[13]=AddStaticVehicle(488,-294.7991,1552.8628,75.5390,272.5410,0,0); // Heli

  • Hir so sollte es gehen:


    Spoiler anzeigen
    //Gantz oben im Script
    enum NewCar
    {
    Carid,
    Float:CarX,
    Float:CarY,
    Float:CarZ,
    Float:CarA,
    vehid
    }
    #define Max_SellCars 9
    new NewsCars[Max_SellCars][NewCar] = {
    {582,-314.7514,1515.3643,75.4135,0.0, -1},
    {582,-317.8429,1515.3643,75.4135,0.0, -1},
    {582,-320.9344,1515.3643,75.4135,0.0, -1},
    {582,-324.0259,1515.3643,75.4135,0.0, -1},
    {582,-327.1174,1515.3643,75.4135,0.0, -1},
    {582,-330.2089,1515.3643,75.4135,0.0, -1},
    {582,-333.3004,1515.3643,75.4135,0.0, -1},
    {582,-336.3919,1515.3643,75.4135,0.0, -1},
    {582,-339.4834,1515.3643,75.4135,0.0, -1},
    {582,-342.5749,1515.3643,75.4135,0.0, -1},
    {582,-345.6664,1515.3643,75.4135,0.0, -1},
    {488,-309.9134,1569.4065,75.5367,275.5628, -1},
    {488,-302.1933,1561.5715,75.5366,277.8422, -1},
    {488,-294.7991,1552.8628,75.5390,272.5410, -1},
    };

    Spoiler anzeigen
    //bei OnGameModeInit:

    Spoiler anzeigen
    for(new i=0; i<sizeof(NewsCars); i++)
    {
    NewsCars[i][vehid]=AddStaticVehicleEx(NewsCars[i][Carid],NewsCars[i][CarX],NewsCars[i][CarY],NewsCars[i][CarZ],NewsCars[i][CarA],0,0,-1);
    }

    Spoiler anzeigen
    //und bei OnGameModeExit
    for(new i=0; i<sizeof(NewsCars); i++)
    {
    DestroyVehicle(NewsCars[i][vehid]);
    }

    Spoiler anzeigen
    //und der befehl:

    Spoiler anzeigen
    ocmd:news(playerid,params[])
    {
    if(PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pLeader] == 4)
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    for(new i=0; i<sizeof(NewsCars); i++)
    {
    if(GetPlayerVehicleID(playerid) == NewsCars[i][vehid])
    {
    new text[128],nr[128];
    if(sscanf(params,"s",text)) return SendClientMessage(playerid,Grau,"[Benutze]: /news [Text]");
    format(nr,sizeof(nr),"NR %s: %s",GetName(playerid),text);
    SendClientMessageToAll(Orange,nr);
    return 1;
    }
    Fehler(playerid,"Du bist in keinem News Fahrzeug!");
    return 1;
    }
    }
    Fehler(playerid,"Du bist in keinem News Fahrzeug!");
    return 1;
    }
    Fehler(playerid,"Du bist kein News Reporter!");
    return 1;
    }

    Mit freundlichen Grüßen,


    Fabi.StaR :love::saint:


  • ich denke mal das liegt an deinem return in der schleife..


    for(new i=0; i<sizeof(NewsCar)+1; i++)//+1 damit die schleife auch bei einer zahl über den newscars wert ankommt. damit in der schleife bei i==sizeof(newscar) returnt werden kann.
    {
    if(i==sizeof(NewsCar))return Fehler(playerid,"Du bist in keinem News Fahrzeug!");
    if(GetPlayerVehicleID(playerid)!=NewsCar[i])continue;
    new text[128],nr[128];
    if(sscanf(params,"s",text)) return SendClientMessage(playerid,Grau,"[Benutze]: /news [Text]");
    format(nr,sizeof(nr),"NR %s: %s",GetName(playerid),text);
    SendClientMessageToAll(Orange,nr);
    return 1;
    }
    keine garantie


    kannst aber auch einen stock erstellen dann ist es etwas übersichtlicher wie ich finde ^^

    stock IsPlayerInNewsCar(playerid)
    {
    for(new i=0;i<sizeof(NewsCar);i++)
    {
    if(GetPlayerVehicleID(playerid)==NewsCar[i])return 1;
    }
    return 0;
    }

    if(IsPlayerInNewsCar(playerid)==0)return Fehler(playerid,"Du bist in keinem News Fahrzeug!");