Problem mit Pickups

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
  • public OnGameModeInit()
    {
    BF_WEAPON[0] = CreateDynamicPickup(342, 1, 120.5242, 1934.8777, 22.7578, 7, -1, -1, 100.0); //Grenade
    BF_WEAPON[1] = CreateDynamicPickup(342, 1, 279.4142, 1829.5718, 21.4766, 7, -1, -1, 100.0); //Grenade
    BF_WEAPON[2] = CreateDynamicPickup(342, 1, 116.2530, 1875.0065, 22.4375, 7, -1, -1, 100.0); //Grenade
    BF_WEAPON[3] = CreateDynamicPickup(342, 1, 136.4600, 1874.9723, 22.4375, 7, -1, -1, 100.0); //Grenade
    BF_WEAPON[4] = CreateDynamicPickup(359, 1, 189.9938, 1940.4785, 17.6406, 7, -1, -1, 100.0); //Rocket Launcher
    BF_WEAPON[5] = CreateDynamicPickup(359, 1, 206.2279, 1932.8312, 23.2422, 7, -1, -1, 100.0); //Rocket Launcher
    BF_WEAPON[6] = CreateDynamicPickup(360, 1, 144.0044, 1850.1791, 25.2610, 7, -1, -1, 100.0); //Heat Seeker
    BF_WEAPON[7] = CreateDynamicPickup(360, 1, 211.4619, 1809.8109, 25.1172, 7, -1, -1, 100.0); //Heat Seeker
    BF_WEAPON[8] = CreateDynamicPickup(360, 1, 146.3869, 1907.3638, 26.3924, 7, -1, -1, 100.0); //Heat Seeker
    BF_WEAPON[9] = CreateDynamicPickup(360, 1, 197.3199, 1835.0059, 23.2422, 7, -1, -1, 100.0); //Heat Seeker
    return DM_OnGameModeInit();
    }


    public OnPlayerPickUpDynamicPickup(playerid, pickupid)
    {
    for(new i = 0; i < 9; i++)
    {
    if(i == 0 || i == 1 || i == 2) GivePlayerWeapon(playerid, GRENADE, 5);
    else if(i == 3 || i == 4 || i == 5) GivePlayerWeapon(playerid, ROCKET_LAUNCHER, 4);
    else if(i == 6 || i == 7 || i == 8 || i == 9) GivePlayerWeapon(playerid, HEAT_SEEKER, 5);
    DestroyDynamicPickup(BF_WEAPON[i]);
    SetTimerEx("PickupRespawn", 45000, false, "i", i);
    }
    return _OnPlayerPickUpDynamicPickup(playerid, pickupid);
    }

    Leider klappt die Geschichte hier nicht. Wenn ich ein Pickup aufnehme, werden alle Pickups im Areal zerstört und respawnen gleichzeitig wieder. Zudem wird die Munition falsch vergeben.
    Weiß jemand weiter?


    Vielen Dank!

    • Offizieller Beitrag

    Deine For-Schleife passt nicht ganz.
    So sollte es klappen:
    if(pickupid == BF_WEAPON[0] || pickupid == BF_WEAPON[1] || pickupid == BF_WEAPON[2]) GivePlayerWeapon(playerid, GRENADE, 5);
    else if(pickupid == BF_WEAPON[3] || pickupid == BF_WEAPON[4] || pickupid == BF_WEAPON[5]) GivePlayerWeapon(playerid, ROCKET_LAUNCHER, 4);
    else if(pickupid == BF_WEAPON[6] || pickupid == BF_WEAPON[7] || pickupid == BF_WEAPON[8] || pickupid == BF_WEAPON[9]) GivePlayerWeapon(playerid, HEAT_SEEKER, 5);
    DestroyDynamicPickup(pickupid);
    for(new i; i < 9; i++) {
    if(pickupid == BF_WEAPON[i]) {
    SetTimerEx("PickupRespawn", 45000, false, "i", i);
    return 1;
    }
    }
    Edit: Entferne deine Forschleife :D

    • Offizieller Beitrag

    Gerne.
    Falls du vor hast weitere Pickup zu erstellen wäre
    es so besser:
    new pickID = -1;
    for(new i; i < 9; i++) {
    if(pickupid == BF_WEAPON[i]) pickID = i;
    if(pickID != -1) {
    switch(pickID) {
    case 0, 1, 2: GivePlayerWeapon(playerid, GRENADE, 5);
    case 3, 4, 5: GivePlayerWeapon(playerid, ROCKET_LAUNCHER, 5);
    case 6, 7, 8, 9: GivePlayerWeapon(playerid, HEAT_SEEKER, 5);
    }
    DestroyDynamicPickup(pickupid);
    SetTimerEx("PickupRespawn", 45000, false, "i", pickID);
    return 1;
    }
    }