Anit-Auto-Respawn

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
  • Ich hab ein Menü erstellt zum Autokaufen, welches auch funktioniert. Die Autos, de man kauft sollen einmalig sein, also nicht wieder spawnen. Hat einer 'ne Idee, wie man das macht?
    Hier ein Teil aus'm Skript:
    case 0: //Admiral
    {
    if(Money>=35000)
    {
    GivePlayerMoney(playerid,-35000);
    CreateVehicle(445,2125.8171,-1134.4524,25.4594,354.0291,-1,-1,-1);
    TogglePlayerControllable(playerid,1);
    }
    else if(Money<35000)
    {
    SendClientMessage(playerid,RED,"You have not got enough money!");
    ShowMenuForPlayer(BuyACarMenu,playerid);
    }
    }

    2 Mal editiert, zuletzt von DuffMan ()

  • //Ganz nach oben:
    new nichtr[MAX_VEHICLES];
    //dann:
    case 0: //Admiral
    {
    if(Money>=35000)
    {
    GivePlayerMoney(playerid,-35000);
    new gla=CreateVehicle(445,2125.8171,-1134.4524,25.4594,354.0291,-1,-1,-1);
    nichtr[gla]=1;
    TogglePlayerControllable(playerid,1);
    }
    else if(Money<35000)
    {
    SendClientMessage(playerid,RED,"You have not got enough money!");
    ShowMenuForPlayer(BuyACarMenu,playerid);
    }
    }
    //OnVehicleDeath:
    if(nichtr[vehicleid]==1) {
    nichtr[vehicleid]=0;
    DestroyVehicle(vehicleid); }

  • Jap... (das knüpft jetzt ans alte an)
    //ganz nach oben:
    new seinauto[MAX_PLAYERS], autoweg[MAX_VEHICLES];
    forward autoputt(aid);
    #define entfernzeit 60//zeit in sekunden, bis das auto entfernt wird
    //OnPlayerStateChange:
    if(newstate==2) {
    new aid=GetPlayerVehicleID(playerid);
    if(nichtr[aid]==1) {
    KillTimer(autoweg[aid]);
    seinauto[playerid]=aid+1; }}
    else if(oldstate==2) {
    if(seinauto[playerid]!=0) {
    seinauto[playerid]--;
    autoweg[seinauto[playerid]]=SetTimerEx("autoputt",entfernzeit*1000,0,"d",seinauto[playerid]);
    seinauto[playerid]=0; }}
    //ganz nach unten:
    public autoweg(aid) {
    DestroyVehicle(aid);
    return 1;
    }
    //OnPlayerDisconnect:
    if(seinauto[playerid]!=0) {
    seinauto[playerid]--;
    autoweg[seinauto[playerid]]=SetTimerEx("autoputt",entfernzeit*1000,0,"d",seinauto[playerid]);
    seinauto[playerid]=0; }

  • Danke, aber es gibt zwei Errors:
    C:\Programme\Rockstar Games\Grand Theft Auto San Andreas\gamemodes\Simpsons.pwn(493) : error 021: symbol already defined: "autoweg"
    C:\Programme\Rockstar Games\Grand Theft Auto San Andreas\gamemodes\Simpsons.pwn(496) : error 010: invalid function or declaration
    public autoweg(aid)//493
    {//494
    DestroyVehicle(aid);//495
    return 1;//496
    }//497

  • Zitat

    Hast du auch lange genug gewartet?


    Ja, hab' ich. (1min.)

    Zitat

    Wie kan man das machen, das kein fahrzeug respawnt, ein ganz normales mit AddStaticVehicle ?


    Ja, aberAddStaticVehicle kann man doch nur unter OnGameModeInit setzen und nicht irgendwo im Skript.


    Hab ich was falsch gemacht?:
    new nichtr[MAX_VEHICLES];
    new seinauto[MAX_PLAYERS], autoweg[MAX_VEHICLES];


    forward autoputt(aid);


    public OnPlayerDisconnect(playerid, reason)
    {
    if(seinauto[playerid]!=0)
    {
    seinauto[playerid]--;
    autoweg[seinauto[playerid]]=SetTimerEx("autoputt",entfernzeit*1000,0,"d",seinauto[playerid]);
    seinauto[playerid]=0;
    }
    new pName[MAX_PLAYER_NAME], string[56];
    GetPlayerName(playerid, pName, sizeof(pName));
    switch(reason)
    {
    case 0: format(string, sizeof(string), "*** %s has left the server. (Lost Connection)", pName);
    case 1: format(string, sizeof(string), "*** %s has left the server. (Leaving)", pName);
    case 2: format(string, sizeof(string), "*** %s has left the server. (Kicked/Banned)", pName);
    }
    SendClientMessageToAll(GREY, string);
    return 1;
    }


    public OnPlayerStateChange(playerid,newstate,oldstate)
    {
    new aid=GetPlayerVehicleID(playerid);
    if(GetPlayerState(playerid)==2)
    {
    new string[128];
    format(string,sizeof(string),"~g~%s",vNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
    GameTextForPlayer(playerid,string,2000,1);
    }
    else if(newstate==2)
    {
    //new aid=GetPlayerVehicleID(playerid);
    if(nichtr[aid]==1)
    {
    KillTimer(autoweg[aid]);
    seinauto[playerid]=aid+1;
    }
    else if(oldstate==2)
    {
    if(seinauto[playerid]!=0)
    {
    seinauto[playerid]--;
    autoweg[seinauto[playerid]]=SetTimerEx("autoputt",entfernzeit*1000,0,"d",seinauto[playerid]);
    seinauto[playerid]=0;
    }
    }
    }
    return 1;
    }


    public autoputt(aid)
    {
    DestroyVehicle(aid);
    return 1;
    }


    public OnPlayerSelectedMenuRow(playerid,row)
    {
    new Menu:CurrentMenu = GetPlayerMenu(playerid);
    new Money;
    Money=GetPlayerMoney(playerid);
    if(CurrentMenu==BuyACarMenu)
    {
    switch(row)
    {
    case 0: //Admiral
    {
    if(Money>=35000)
    {
    GivePlayerMoney(playerid,-35000);
    new currentCar=CreateVehicle(445,2125.8171,-1134.4524,25.4594,354.0291,-1,-1,-1);
    nichtr[currentCar]=1;
    TogglePlayerControllable(playerid,1);
    }
    else if(Money<35000)
    {
    SendClientMessage(playerid,RED,"You have not got enough money!");
    ShowMenuForPlayer(BuyACarMenu,playerid);
    }
    }
    case 1: //Buffalo
    {
    if(Money>=35000)
    {
    GivePlayerMoney(playerid,-35000);
    new currentCar=CreateVehicle(402,2125.8171,-1134.4524,25.4594,354.0291,-1,-1,-1);
    nichtr[currentCar]=1;
    TogglePlayerControllable(playerid,1);
    }
    else if(Money<35000)
    {
    SendClientMessage(playerid,RED,"You have not got enough money!");
    ShowMenuForPlayer(BuyACarMenu,playerid);
    }
    }
    case 2: //Camper
    {
    if(Money>=26000)
    {
    GivePlayerMoney(playerid,-35000);
    new currentCar=CreateVehicle(483,2125.8171,-1134.4524,25.4594,354.0291,-1,-1,-1);
    nichtr[currentCar]=1;
    TogglePlayerControllable(playerid,1);
    }
    else if(Money<26000)
    {
    SendClientMessage(playerid,RED,"You have not got enough money!");
    ShowMenuForPlayer(BuyACarMenu,playerid);
    }
    }
    case 3: //Hotring Racer
    {
    if(Money>=50000||Money==50000)
    {
    GivePlayerMoney(playerid,-50000);
    new currentCar=CreateVehicle(503,2125.8171,-1134.4524,25.4594,354.0291,-1,-1,-1);
    nichtr[currentCar]=1;
    TogglePlayerControllable(playerid,1);
    }
    else if(Money<35000)
    {
    SendClientMessage(playerid,RED,"You have not got enough money!");
    ShowMenuForPlayer(BuyACarMenu,playerid);
    }
    }
    case 4: //Rancher
    {
    if(Money>=40000)
    {
    GivePlayerMoney(playerid,-40000);
    new currentCar=CreateVehicle(489,2125.8171,-1134.4524,25.4594,354.0291,-1,-1,-1);
    nichtr[currentCar]=1;
    TogglePlayerControllable(playerid,1);
    }
    else if(Money<40000)
    {
    SendClientMessage(playerid,RED,"You have not got enough money!");
    ShowMenuForPlayer(BuyACarMenu,playerid);
    }
    }
    case 5: //Slamvan
    {
    if(Money>=19000)
    {
    GivePlayerMoney(playerid,-19000);
    new currentCar=CreateVehicle(535,2125.8171,-1134.4524,25.4594,354.0291,-1,-1,1000);
    nichtr[currentCar]=1;
    TogglePlayerControllable(playerid,1);
    }
    else if(Money<19000)
    {
    SendClientMessage(playerid,RED,"You have not got enough money!");
    ShowMenuForPlayer(BuyACarMenu,playerid);
    }
    }
    }
    }
    return 1;
    }


    public OnVehicleDeath(vehicleid,killerid)
    {
    if(nichtr[vehicleid]==1)
    {
    nichtr[vehicleid]=0;
    DestroyVehicle(vehicleid);
    }
    return 1;
    }

    3 Mal editiert, zuletzt von DuffMan ()