In der nähe von den Sprunk F drücken?

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
  • Hallo,
    ich möchte es so machen wenn man in der nähe des Automaten ist das man F drückt leben bekommt und dann eine Animation kommt.
    #include <a_samp>
    #define MAX_MACHINES 10 // CHANGE IF YOU'RE USING A STREAMER AND WILLING TO ADD MORE
    #define MACHINE_CASH 5 // Cost - Default is $1


    //**VARIABLES**//
    enum fMachines
    {
    Float:fmX,
    Float:fmY,
    Float:fmZ,
    fmType
    };
    new FoodMachines[MAX_MACHINES][fMachines];
    new Machine = 1;
    new SprunkMachine[MAX_MACHINES];
    new CandyMachine[MAX_MACHINES];
    new Anim[200];
    //**FORWARDS**//
    forward MachineAnimation(playerid);
    /*x---------------------------------CallBacks-------------------------------------x*/
    stock Seif_PlayerToPoint(playerid,Float:radi, Float:px, Float:py, Float:pz)
    {
    if(IsPlayerConnected(playerid))
    {
    new Float:x, Float:y, Float:z;
    new Float:ox, Float:oy, Float:oz;
    GetPlayerPos(playerid, ox, oy, oz);
    x = (ox -px);
    y = (oy -py);
    z = (oz -pz);
    if (((x < radi) && (x > -radi)) && ((y < radi) && (y > -radi)) && ((z < radi) && (z > -radi))) return 1;
    }
    return 0;
    }


    AddSprunkMachine(Float:X,Float:Y,Float:Z,Float:rX,Float:rY,Float:rZ)
    {
    Machine++;
    SprunkMachine[Machine] = CreateObject(955,X,Y,Z,rX,rY,rZ);
    FoodMachines[Machine][fmX] = X;
    FoodMachines[Machine][fmY] = Y;
    FoodMachines[Machine][fmZ] = Z;
    FoodMachines[Machine][fmType] = 1;
    }


    AddCandyMachine(Float:X,Float:Y,Float:Z,Float:rX,Float:rY,Float:rZ)
    {
    Machine++;
    CandyMachine[Machine] = CreateObject(956,X,Y,Z,rX,rY,rZ);
    FoodMachines[Machine][fmX] = X;
    FoodMachines[Machine][fmY] = Y;
    FoodMachines[Machine][fmZ] = Z;
    FoodMachines[Machine][fmType] = 2;
    }


    public MachineAnimation(playerid)
    {
    if (Anim[playerid] == 1) ApplyAnimation(playerid,"VENDING","VEND_Drink2_P",4.1,0,1,1,1,1), Anim[playerid] = 0 ,SetTimerEx("MachineAnimation",1000,0,"d",playerid);
    else if (Anim[playerid] == 2) ApplyAnimation(playerid,"VENDING","VEND_Eat_P",4.1,0,1,1,1,1), Anim[playerid] = 0, SetTimerEx("MachineAnimation",1000,0,"d",playerid);
    else if (Anim[playerid] == 0) ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0);
    return 1;
    }

  • #include <a_samp>
    #define MAX_MACHINES 10 // CHANGE IF YOU'RE USING A STREAMER AND WILLING TO ADD MORE
    #define MACHINE_CASH 5 // Cost - Default is $1


    //**VARIABLES**//
    enum fMachines
    {
    Float:fmX,
    Float:fmY,
    Float:fmZ,
    Float:fmrZ,
    fmType
    };
    new FoodMachines[MAX_MACHINES][fMachines];
    new Machine = -1;
    new SprunkMachine[MAX_MACHINES];
    new CandyMachine[MAX_MACHINES];


    AddSprunkMachine(Float:X,Float:Y,Float:Z,Float:rX,Float:rY,Float:rZ)
    {
    Machine++;
    SprunkMachine[Machine] = CreateObject(955,X,Y,Z,rX,rY,rZ);
    FoodMachines[Machine][fmX] = X;
    FoodMachines[Machine][fmY] = Y;
    FoodMachines[Machine][fmZ] = Z;
    FoodMachines[Machine][fmrZ] = rZ;
    FoodMachines[Machine][fmType] = 1;
    }


    AddCandyMachine(Float:X,Float:Y,Float:Z,Float:rX,Float:rY,Float:rZ)
    {
    Machine++;
    CandyMachine[Machine] = CreateObject(956,X,Y,Z,rX,rY,rZ);
    FoodMachines[Machine][fmX] = X;
    FoodMachines[Machine][fmY] = Y;
    FoodMachines[Machine][fmZ] = Z;
    FoodMachines[Machine][fmrZ] = rZ;
    FoodMachines[Machine][fmType] = 2;
    }


    stock GetPlayerMachine(playerid)
    {
    new Float:x, Float:y;
    for(new i = 0; i < Machine+1; i++)
    {
    x = FoodMachines[i][fmX] + (1.0 * floatsin(-FoodMachines[i][fmrZ], degrees));
    y = FoodMachines[i][fmY] + (1.0 * floatcos(-FoodMachines[i][fmrZ], degrees));
    if(IsPlayerInRangeOfPoint(playerid, 0.8, x, y, FoodMachines[i][fmZ])) return i;
    }
    return -1;
    }


    forward MachineAnimation(playerid, anim);
    public MachineAnimation(playerid, anim)
    {
    if (anim == 1)
    {
    ApplyAnimation(playerid,"VENDING","VEND_Drink2_P",4.1,0,1,1,1,1);
    SetTimerEx("MachineAnimation",1000,0,"dd",playerid,0);
    }
    else if (anim == 2)
    {
    ApplyAnimation(playerid,"VENDING","VEND_Eat_P",4.1,0,1,1,1,1);
    SetTimerEx("MachineAnimation",1000,0,"dd",playerid,0);
    }
    else ApplyAnimation(playerid, "CARRY", "crry_prtial", 4.0, 0, 0, 0, 0, 0);
    return 1;
    }


    public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
    if (newkeys & KEY_SECONDARY_ATTACK)
    {
    new id = GetPlayerMachine(playerid);
    if(id != -1)
    {
    MachineAnimation(playerid, FoodMachines[id][fmType]);
    //Geld abziehen
    //Health geben
    }
    }
    return 1;
    }