resourcen freundlicher ?

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
  • Guten Abend Community,


    ich wollte euch mal fragen:
    Kann man diesen Code:



    forward bsn1(playerid);
    forward bsn2(playerid);forward bsn3(playerid);
    forward bsn4(playerid);
    forward bsn5(playerid);
    forward bsn6(playerid);
    forward bsn7(playerid);
    forward bsn8(playerid);
    forward bsn9(playerid);



    public bsn1(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,10);
    GivePlayerMoney(playerid,-10);
    return 1;
    }


    public bsn2(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,10);
    GivePlayerMoney(playerid,-10);
    return 1;
    }


    public bsn3(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,15);
    GivePlayerMoney(playerid,-15);
    return 1;
    }


    public bsn4(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,5);
    GivePlayerMoney(playerid,-5);
    return 1;
    }


    public bsn5(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,25);
    GivePlayerMoney(playerid,-50);
    return 1;
    }


    public bsn6(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,30);
    GivePlayerMoney(playerid,-60);
    return 1;
    }


    public bsn7(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,40);
    GivePlayerMoney(playerid,-70);
    return 1;
    }


    public bsn8(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,5);
    GivePlayerMoney(playerid,-2);
    return 1;
    }


    public bsn9(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,50);
    GivePlayerMoney(playerid,-100);
    return 1;
    }


    irgendwie resourcend freundlicher scripten ?

  • Mhm wie wäre es wenn du die Funktion erst gar nicht aufrufst sonder direkt aus führen lässt?

    "Bevor ich mir Informationen aus der "Bild" hole,
    werde ich anfangen, Wahlergebnisse danach vorauszusagen,
    neben welchen Busch unsere Katze gepinkelt hat."

    Margarete Stokowski

  • wie meinst du das ?


    der ganze code sicht bei mir so aus :



    #define DIALOG_BSN 1



    new kauf;



    forward bsn1(playerid);
    forward bsn2(playerid);
    forward bsn3(playerid);
    forward bsn4(playerid);
    forward bsn5(playerid);
    forward bsn6(playerid);
    forward bsn7(playerid);
    forward bsn8(playerid);
    forward bsn9(playerid);




    #if defined FILTERSCRIPT





    public OnFilterScriptInit()
    {
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");


    kauf=CreatePickup(1317,1,376.4373,-67.7915,1001.5151,0);
    return 1;
    }


    public OnFilterScriptExit()
    {
    return 1;
    }


    #else


    main()
    {
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
    }


    #endif



    public OnPlayerRequestClass(playerid, classid)
    {
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
    }


    public OnPlayerConnect(playerid)
    {
    return 1;
    }


    public OnPlayerDisconnect(playerid, reason)
    {
    return 1;
    }


    public OnPlayerSpawn(playerid)
    {
    return 1;
    }


    public OnPlayerDeath(playerid, killerid, reason)
    {
    return 1;
    }


    public OnVehicleSpawn(vehicleid)
    {
    return 1;
    }


    public OnVehicleDeath(vehicleid, killerid)
    {
    return 1;
    }


    public OnPlayerText(playerid, text[])
    {
    return 1;
    }


    public OnPlayerCommandText(playerid, cmdtext[])
    {


    return 0;
    }


    public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
    {
    return 1;
    }


    public OnPlayerExitVehicle(playerid, vehicleid)
    {
    return 1;
    }


    public OnPlayerStateChange(playerid, newstate, oldstate)
    {
    return 1;
    }


    public OnPlayerEnterCheckpoint(playerid)
    {
    return 1;
    }


    public OnPlayerLeaveCheckpoint(playerid)
    {
    return 1;
    }


    public OnPlayerEnterRaceCheckpoint(playerid)
    {
    return 1;
    }


    public OnPlayerLeaveRaceCheckpoint(playerid)
    {
    return 1;
    }


    public OnRconCommand(cmd[])
    {
    return 1;
    }


    public OnPlayerRequestSpawn(playerid)
    {
    return 1;
    }


    public OnObjectMoved(objectid)
    {
    return 1;
    }


    public OnPlayerObjectMoved(playerid, objectid)
    {
    return 1;
    }


    public OnPlayerPickUpPickup(playerid, pickupid)
    {
    if(pickupid==kauf)
    {
    ShowPlayerDialog(playerid,DIALOG_BSN,DIALOG_STYLE_LIST,"Bürger Shot Shop","Chicken Bürger 10$ (10HP)\r\n.Cheese Bürger 10$(10HP)\r\n.Chicken Wings 15$ (15HP)\r\n.Hamburger 5$(5HP)\r\n.Big Mac 50$ (25HP)\r\n.Royal TS 60$ (30HP)\r\n.Happy Meal 70$ (40HP)\r\n.Cola 5$ (5HP)\r\n.Saftiges Steak 100$ (50HP)\r","Kaufen","Verlassen");
    return 1;
    }
    return 1;
    }


    public OnVehicleMod(playerid, vehicleid, componentid)
    {
    return 1;
    }


    public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
    {
    return 1;
    }


    public OnVehicleRespray(playerid, vehicleid, color1, color2)
    {
    return 1;
    }


    public OnPlayerSelectedMenuRow(playerid, row)
    {
    return 1;
    }


    public OnPlayerExitedMenu(playerid)
    {
    return 1;
    }


    public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
    {
    return 1;
    }


    public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
    return 1;
    }


    public OnRconLoginAttempt(ip[], password[], success)
    {
    return 1;
    }


    public OnPlayerUpdate(playerid)
    {
    return 1;
    }


    public OnPlayerStreamIn(playerid, forplayerid)
    {
    return 1;
    }


    public OnPlayerStreamOut(playerid, forplayerid)
    {
    return 1;
    }


    public OnVehicleStreamIn(vehicleid, forplayerid)
    {
    return 1;
    }


    public OnVehicleStreamOut(vehicleid, forplayerid)
    {
    return 1;
    }


    public bsn1(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,10);
    GivePlayerMoney(playerid,-10);
    return 1;
    }


    public bsn2(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,10);
    GivePlayerMoney(playerid,-10);
    return 1;
    }


    public bsn3(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,15);
    GivePlayerMoney(playerid,-15);
    return 1;
    }


    public bsn4(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,5);
    GivePlayerMoney(playerid,-5);
    return 1;
    }


    public bsn5(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,25);
    GivePlayerMoney(playerid,-50);
    return 1;
    }


    public bsn6(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,30);
    GivePlayerMoney(playerid,-60);
    return 1;
    }


    public bsn7(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,40);
    GivePlayerMoney(playerid,-70);
    return 1;
    }


    public bsn8(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,5);
    GivePlayerMoney(playerid,-2);
    return 1;
    }


    public bsn9(playerid)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,50);
    GivePlayerMoney(playerid,-100);
    return 1;
    }


    public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
    {
    if(dialogid==DIALOG_BSN)
    {
    if(response==1)
    {
    switch(listitem)
    {
    case 0:
    {
    SetTimer("bsn1",1000*2,false);
    SendClientMessage(playerid,0xD48B00FF,"Dein Chicken Burger kommt gleich");
    }
    case 1:
    {
    SetTimer("bsn2",1000*2,false);
    SendClientMessage(playerid,0xD48B00FF,"Dein Cheese Burger kommt gleich");
    }
    case 2:
    {
    SetTimer("bsn3",1000*2,false);
    SendClientMessage(playerid,0xD48B00FF,"Dein Chicken Wings kommt gleich");
    }
    case 3:
    {
    SetTimer("bsn4",1000*2,false);
    SendClientMessage(playerid,0xD48B00FF,"Dein Hamburger kommt gleich");
    }
    case 4:
    {
    SetTimer("bsn5",1000*2,false);
    SendClientMessage(playerid,0xD48B00FF,"Dein Chicken Burger kommt gleich");
    }
    case 5:
    {
    SetTimer("bsn6",1000*2,false);
    SendClientMessage(playerid,0xD48B00FF,"Dein Big Mac kommt gleich");
    }
    case 6:
    {
    SetTimer("bsn7",1000*2,false);
    SendClientMessage(playerid,0xD48B00FF,"Dein Royal TS kommt gleich");
    }
    case 7:
    {
    SetTimer("bsn8",1000*2,false);
    SendClientMessage(playerid,0xD48B00FF,"Deine Cola kommt gleich");
    }
    case 8:
    {
    SetTimer("bsn9",1000*2,false);
    SendClientMessage(playerid,0xD48B00FF,"Dein Saftiges Steak kommt gleich");
    }
    }


    return 1;
    }
    if(response==0)
    {
    SendClientMessage(playerid,0x4BFF00FF,"Du hast den Kauf Vorgang abgebrochen");
    return 1;
    }
    }
    return 1;
    }


    public OnPlayerClickPlayer(playerid, clickedplayerid, source)
    {
    return 1;
    }


  • Statt
    //code
    bsn1(playerid);
    //code
    einfach
    //code
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,10);
    GivePlayerMoney(playerid,-10);
    //code

    "Bevor ich mir Informationen aus der "Bild" hole,
    werde ich anfangen, Wahlergebnisse danach vorauszusagen,
    neben welchen Busch unsere Katze gepinkelt hat."

    Margarete Stokowski


  • SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,10);
    GivePlayerMoney(playerid,-10);



    immer bei den case setzten oder wie ?
    also so ?



    case 5:
    {
    SetTimer("bsn6",1000*2,false);
    SendClientMessage(playerid,0xD48B00FF,"Dein Big Mac kommt gleich");
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    SetPlayerHealth(playerid,10);
    GivePlayerMoney(playerid,-10);
    }


  • achso du machst das mit nem Timer
    dann vergiss was ich sagte
    das geht einfacher


    //kein switch case
    SetTimer("bsn",1000*2,false,"ii",playerid,listitem);
    //funktion
    public bsn(playerid,index)
    {
    SendClientMessage(playerid,0x0037FFFF,"Guten Appitet");
    switch(index)
    {
    case 5: //wäre hier bsn6
    {
    SetPlayerHealth(playerid,30);
    GivePlayerMoney(playerid,-60);
    }
    //etc
    }
    return true;
    }

    "Bevor ich mir Informationen aus der "Bild" hole,
    werde ich anfangen, Wahlergebnisse danach vorauszusagen,
    neben welchen Busch unsere Katze gepinkelt hat."

    Margarete Stokowski

  • BSN(playerid, cost, Float:health);
    public BSN(playerid, cost, Float:health)
    {
    new Float:oldhealth;
    SendClientMessage(playerid, 0x0037FFFF, "Guten Appetit!");
    GetPlayerHealth(playerid, oldhealth);
    oldhealth += health;
    if (oldhealth > 100.0)
    oldhealth = 100.0;
    SetPlayerHealth(playerid, oldhealth);
    GivePlayerMoney(playerid, -1 * cost);
    }


    SetTimerEx("BSN", 1000 * 2, false, "iif", playerid, 10, 15.0);