GetWeaponIDByName geht nicht

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.
    Undzwar wollte ich eine Funktion machen, die die Waffen ID rausfindet, wenn man den Namen eingibt. Aber es gibt ohne Ende Error. Bei jeder u.g. Zeile



    new weapon = GetWeaponIDByName(wname); //ERROR
    GivePlayerWeapon(pID, weapon, ammo);


    stock GetWeaponIDByName(weaponname) {
    new weaponid;
    if(weaponname == "schlagring" || weaponname == "knuckle" || weaponname == 1) {weaponid = 1; return weaponid;}
    else if(weaponname == "golfschläger" || weaponname == "golfschlaeger" || weaponname == "golf club"|| weaponname == "golf" || weaponname == 2) {weaponid = 2;return weaponid;}
    else if(weaponname == "schlagstock" || weaponname == "stick" || weaponname == "nite stick" || weaponname == 3) {weaponid = 3;return weaponid;}
    else if(weaponname == "messer" || weaponname == "taschenmesser" || weaponname == "knife"|| weaponname == 4) {weaponid = 4;return weaponid;}
    else if(weaponname == "baseballschläger" || weaponname == "schläger" || weaponname == "baseball bat"|| weaponname == "bat"|| weaponname == 5) {weaponid = 5;return weaponid;}
    else if(weaponname == "schaufel" || weaponname == "shovel" || weaponname == 6) {weaponid = 6;return weaponid;}
    else if(weaponname == "billiard" || weaponname == "pool cue" || weaponname == 7) {weaponid = 7;return weaponid;}
    else if(weaponname == "katana" || weaponname == "schwert" || weaponname == 8) {weaponid = 8;return weaponid;}
    else if(weaponname == "kettensäge" || weaponname == "chainsaw" || weaponname == 9) {weaponid = 9;return weaponid;}
    else if(weaponname == "dildo" || weaponname == 10|| weaponname == 13) {weaponid = 10;return weaponid;}
    else if(weaponname == "vibrator" || weaponname == 11 || weaponname == 12) {weaponid = 12;return weaponid;}
    else if(weaponname == "dildo" || weaponname == 13) {weaponid = 13;return weaponid;}
    else if(weaponname == "blumenstrauß" || weaponname == "blumen" || weaponname == "flowers"|| weaponname == 14) {weaponid = 14;return weaponid;}
    else if(weaponname == "granate" || weaponname == "grenade" || weaponname == 16) {weaponid = 16;return weaponid;}
    else if(weaponname == "tränengas" || weaponname == "tear gas" || weaponname == 17) {weaponid = 17;return weaponid;}
    else if(weaponname == "molotov" || weaponname == "molotov cocktail" || weaponname == 18) {weaponid = 18;return weaponid;}
    else if(weaponname == "9mm" || weaponname == "pistol" || weaponname == 22) {weaponid = 22;return weaponid;}
    else if(weaponname == "schalgedämpfte 9mm" || weaponname == "silenced pistol" || weaponname == 23) {weaponid = 23;return weaponid;}
    else if(weaponname == "deagle" || weaponname == "desert eagle" || weaponname == 24) {weaponid = 24;return weaponid;}
    else if(weaponname == "shotgun" || weaponname == "schrottflinte" || weaponname == 25) {weaponid = 25;return weaponid;}
    else if(weaponname == "abgesägte schrottflinte" || weaponname == "sawn-off shotgun" || weaponname == 26) {weaponid = 26;return weaponid;}
    else if(weaponname == "micro uzi"|| weaponname == "uzi" || weaponname == 28) {weaponid = 28;return weaponid;}
    else if(weaponname == "mp5" || weaponname == 29) {weaponid = 29;return weaponid;}
    else if(weaponname == "ak47" || weaponname == 30) {weaponid = 30;return weaponid;}
    else if(weaponname == "m4" || weaponname == 31) {weaponid = 31;return weaponid;}
    else if(weaponname == "tec9" || weaponname == 32) {weaponid = 32;return weaponid;}
    else if(weaponname == "country rifle" || weaponname == 33) {weaponid = 33;return weaponid;}
    else if(weaponname == "sniper rifle"|| weaponname == "sniper" || weaponname == 34) {weaponid = 34;return weaponid;}
    else if(weaponname == "RPG" || weaponname == 35) {weaponid = 35;return weaponid;}
    else if(weaponname == "flammenwerfer" || weaponname == 37) {weaponid = 37;return weaponid;}
    else if(weaponname == "minigun" || weaponname == 38) {weaponid = 38;return weaponid;}
    else if(weaponname == "rucksackbombe" || weaponname == 39) {weaponid = 39;return weaponid;}
    else if(weaponname == "detonator" || weaponname == 40) {weaponid = 40;return weaponid;}
    else if(weaponname == "sprühdose"|| weaponname == "spray can" || weaponname == 41) {weaponid = 41;return weaponid;}
    else if(weaponname == "feuerlöscher"|| weaponname == "extinguisher" || weaponname == 42) {weaponid = 42;return weaponid;}
    else if(weaponname == "kamera"|| weaponname == "camera" || weaponname == 43) {weaponid = 43;return weaponid;}
    else if(weaponname == "nachtsichgerät"|| weaponname == "night vision" || weaponname == 44) {weaponid = 44;return weaponid;}
    else if(weaponname == "infrarotbrille"|| weaponname == "thermobrille" || weaponname == 45) {weaponid = 45;return weaponid;}
    else if(weaponname == "fallschirm"|| weaponname == "parachute" || weaponname == 46) {weaponid = 46;return weaponid;}
    else {return 0;}
    }


    Fehler sind:



    LG
    Maydo


    Kostenlose Pawno Alternative / PAWN IDE -> PawnStar
    Mass Effect
    :love:

  • stock GetWeaponIDByName(weaponname) {
    zu
    stock GetWeaponIDByName(weaponname[]) {


    und in deinen if's eben mit strcmp arbeiten statt ==


    Mein CS:GO Server: 62.75.168.39:27016


    Ich bin so hungrig, dass ich vor lauter Durst nicht weiß, was ich rauchen soll - so müde bin ich!
    Freedom is just another word for 'Nothing left to lose'

  • Geht doch irgendwie nicht. ER gibt mir immer nur einen Dildo:
    LeijaT:

    stock GetWeaponIDByName(weaponname[]) {
    new weaponid;
    if(strcmp(weaponname,"schlagring", true) == 0 || strcmp(weaponname,"knuckle", true) == 0 || strcmp(weaponname,"1") == 0) {weaponid = 1; return weaponid;}
    else if(strcmp(weaponname,"golfschläger", true) == 0 || strcmp(weaponname ,"golfschlaeger", true) == 0 || strcmp(weaponname, "golf club", true) == 0|| strcmp(weaponname ,"golf", true) == 0 || strcmp(weaponname, "2") == 0) {weaponid = 2;return weaponid;}
    else if(strcmp(weaponname, "schlagstock", true) == 0 || strcmp(weaponname, "stick", true) == 0 || strcmp(weaponname, "nite stick", true) == 0 || strcmp(weaponname, "3") == 0) {weaponid = 3;return weaponid;}
    else if(strcmp(weaponname , "messer", true) == 0 || strcmp(weaponname, "taschenmesser", true) == 0 || strcmp(weaponname, "knife", true) == 0|| strcmp(weaponname,"4") == 0) {weaponid = 4;return weaponid;}
    else if(strcmp(weaponname, "baseballschläger", true) == 0 || strcmp(weaponname ,"schläger", true) == 0 || strcmp(weaponname, "baseball bat", true ) == 0|| strcmp(weaponname, "bat") == 0|| strcmp(weaponname, "5") == 0) {weaponid = 5;return weaponid;}
    else if(strcmp(weaponname, "schaufel", true) == 0 || strcmp(weaponname ,"shovel", true) == 0 || strcmp(weaponname , "6") == 0) {weaponid = 6;return weaponid;}
    else if(strcmp(weaponname ,"billiard", true) == 0|| strcmp(weaponname, "pool cue", true) == 0 || strcmp(weaponname , "7") == 0) {weaponid = 7;return weaponid;}
    else if(strcmp(weaponname , "katana", true) == 0 || strcmp(weaponname , "schwert", true) == 0 || strcmp(weaponname , "8", true) == 0) {weaponid = 8;return weaponid;}
    else if(strcmp(weaponname , "kettensäge", true) == 0 || strcmp(weaponname , "chainsaw", true) == 0 || strcmp(weaponname , "9", true) == 0) {weaponid = 9;return weaponid;}
    else if(strcmp(weaponname , "dildo", true) == 0 || strcmp(weaponname , "10") == 0|| strcmp(weaponname , "13")) {weaponid = 10;return weaponid;}
    else if(strcmp(weaponname , "vibrator", true) == 0 || strcmp(weaponname , "11") == 0 || strcmp(weaponname, "12")== 0) {weaponid = 12;return weaponid;}
    else if(strcmp(weaponname , "dildo", true) == 0 || strcmp(weaponname , "13")== 0) {weaponid = 13;return weaponid;}
    else if(strcmp(weaponname , "blumenstrauß", true) == 0 || strcmp(weaponname , "blumen", true) == 0 || strcmp(weaponname , "flowers", true) == 0|| strcmp(weaponname , "14")== 0) {weaponid = 14;return weaponid;}
    else if(strcmp(weaponname , "granate", true) == 0 || strcmp(weaponname , "grenade", true) == 0 || strcmp(weaponname , "16", true) == 0) {weaponid = 16;return weaponid;}
    else if(strcmp(weaponname , "tränengas", true) == 0 || strcmp(weaponname , "tear gas", true) == 0 || strcmp(weaponname , "17")==0) {weaponid = 17;return weaponid;}
    else if(strcmp(weaponname , "molotov", true) == 0 || strcmp(weaponname , "molotov cocktail", true) == 0 || strcmp(weaponname ,"18")== 0) {weaponid = 18;return weaponid;}
    else if(strcmp(weaponname , "9mm", true) == 0 || strcmp(weaponname , "pistol", true) == 0 || strcmp(weaponname , "22")== 0) {weaponid = 22;return weaponid;}
    else if(strcmp(weaponname , "schalgedämpfte 9mm", true) == 0 || strcmp(weaponname , "silenced pistol", true) == 0 || strcmp(weaponname , "23")==0) {weaponid = 23;return weaponid;}
    else if(strcmp(weaponname , "deagle", true) == 0 || strcmp(weaponname, "desert eagle", true) == 0 || strcmp(weaponname , "24")==0) {weaponid = 24;return weaponid;}
    else if(strcmp(weaponname , "shotgun", true) == 0 || strcmp(weaponname , "schrottflinte", true) == 0 || strcmp(weaponname , "25")==0) {weaponid = 25;return weaponid;}
    else if(strcmp(weaponname , "abgesägte schrottflinte", true) == 0 || strcmp(weaponname , "sawn-off shotgun", true) == 0 || strcmp(weaponname , "26") == 0) {weaponid = 26;return weaponid;}
    else if(strcmp(weaponname , "micro uzi", true) == 0|| strcmp(weaponname , "uzi", true) == 0 || strcmp(weaponname , "28")==0) {weaponid = 28;return weaponid;}
    else if(strcmp(weaponname , "mp5", true) == 0 || strcmp(weaponname , "29") == 0) {weaponid = 29;return weaponid;}
    else if(strcmp(weaponname , "ak47", true) == 0 || strcmp(weaponname , "30") == 0) {weaponid = 30;return weaponid;}
    else if(strcmp(weaponname , "m4", true) == 0 || strcmp(weaponname , "31") == 0) {weaponid = 31;return weaponid;}
    else if(strcmp(weaponname , "tec9", true) == 0 || strcmp(weaponname , "32") == 0) {weaponid = 32;return weaponid;}
    else if(strcmp(weaponname , "country rifle", true) == 0 || strcmp(weaponname , "33") == 0) {weaponid = 33;return weaponid;}
    else if(strcmp(weaponname , "sniper rifle", true) == 0|| strcmp(weaponname , "sniper", true) == 0 || strcmp(weaponname , "34") == 0) {weaponid = 34;return weaponid;}
    else if(strcmp(weaponname , "RPG", true) == 0 || strcmp(weaponname, "35") == 0) {weaponid = 35;return weaponid;}
    else if(strcmp(weaponname , "flammenwerfer", true) == 0 || strcmp(weaponname , "37") == 0) {weaponid = 37;return weaponid;}
    else if(strcmp(weaponname , "minigun", true) == 0 || strcmp(weaponname , "38") == 0) {weaponid = 38;return weaponid;}
    else if(strcmp(weaponname , "rucksackbombe", true) == 0 || strcmp(weaponname ,"39") == 0) {weaponid = 39;return weaponid;}
    else if(strcmp(weaponname , "detonator", true) == 0 || strcmp(weaponname , "40") == 0) {weaponid = 40;return weaponid;}
    else if(strcmp(weaponname , "sprühdose", true) == 0|| strcmp(weaponname , "spray can", true) == 0 || strcmp(weaponname , "41") == 0) {weaponid = 41;return weaponid;}
    else if(strcmp(weaponname , "feuerlöscher", true) == 0|| strcmp(weaponname , "extinguisher", true) == 0 || strcmp(weaponname , "42") == 0) {weaponid = 42;return weaponid;}
    else if(strcmp(weaponname , "kamera", true) == 0|| strcmp(weaponname , "camera", true) == 0 || strcmp(weaponname , "43") == 0) {weaponid = 43;return weaponid;}
    else if(strcmp(weaponname , "nachtsichgerät", true) == 0|| strcmp(weaponname , "night vision", true) == 0 || strcmp(weaponname , "44") == 0) {weaponid = 44;return weaponid;}
    else if(strcmp(weaponname , "infrarotbrille", true) == 0|| strcmp(weaponname , "thermobrille", true) == 0 || strcmp(weaponname , "45") == 0) {weaponid = 45;return weaponid;}
    else if(strcmp(weaponname , "fallschirm", true) == 0|| strcmp(weaponname , "parachute", true) == 0 || strcmp(weaponname , "46") == 0) {weaponid = 46;return weaponid;}
    else {return 0;}
    }


    Kostenlose Pawno Alternative / PAWN IDE -> PawnStar
    Mass Effect
    :love:

  • ocmd:agiveweapon(playerid, params[]){
    new pID, wname[64], ammo;
    if(pData[playerid][pEingeloggt] == 0) return SendClientMessage(playerid, COLOR_ERROR, "[Fehler]{FFFFFF} Du musst eingeloggt sein, um Befehle auszuführen!");
    if(pData[playerid][pAdmin] < 3 && pData[playerid][pAduty] == 1) return SendClientMessage(playerid, COLOR_ERROR, "[Fehler]{FFFFFF} Du hast nicht die nötigen Berechtigungen dazu!");
    if(sscanf(params, "usd", pID, wname, ammo)) return SendClientMessage(playerid, COLOR_USING, "[Benutzung]{FFFFFF} /agiveweapon [ID][Waffenname][Munition]");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, COLOR_ERROR, "[Fehler]{FFFFFF} Fehlerhafte ID!");

    new weapon = GetWeaponIDByName(wname);
    GivePlayerWeapon(pID, weapon, ammo);

    return 1;
    }


    Kostenlose Pawno Alternative / PAWN IDE -> PawnStar
    Mass Effect
    :love:

  • Versuch mal folgende Zeile:
    if(sscanf(params, "usd", pID, wname, ammo)) return SendClientMessage(playerid, COLOR_USING, "[Benutzung]{FFFFFF} /agiveweapon [ID][Waffenname][Munition]");
    in
    if(sscanf(params, "us[64]d", pID, wname, ammo)) return SendClientMessage(playerid, COLOR_USING, "[Benutzung]{FFFFFF} /agiveweapon [ID][Waffenname][Munition]");
    zu ändern.


    Mein CS:GO Server: 62.75.168.39:27016


    Ich bin so hungrig, dass ich vor lauter Durst nicht weiß, was ich rauchen soll - so müde bin ich!
    Freedom is just another word for 'Nothing left to lose'

  • Versuch mal folgende Zeile:
    if(sscanf(params, "usd", pID, wname, ammo)) return SendClientMessage(playerid, COLOR_USING, "[Benutzung]{FFFFFF} /agiveweapon [ID][Waffenname][Munition]");
    in
    if(sscanf(params, "us[64]d", pID, wname, ammo)) return SendClientMessage(playerid, COLOR_USING, "[Benutzung]{FFFFFF} /agiveweapon [ID][Waffenname][Munition]");
    zu ändern.


    Weiterhin pinker Dildo


    Kostenlose Pawno Alternative / PAWN IDE -> PawnStar
    Mass Effect
    :love:

  • Dann lass dir mal die konvertierte WeaponID via SendClientMessage oder printf ausgeben. Der Fehler wird ja vermutlich da liegen.


    Mein CS:GO Server: 62.75.168.39:27016


    Ich bin so hungrig, dass ich vor lauter Durst nicht weiß, was ich rauchen soll - so müde bin ich!
    Freedom is just another word for 'Nothing left to lose'

  • Dann schlag ich dir diesen Schnipsel vor


    stock GetWeaponID(name[])
    {
    for(new wps=0; wps < 48; wps++)
    {
    if (wps==19||wps==20||wps== 21) continue;
    if (strfind(WeaponNames[wps],name, true) != -1) {
    return wps;
    }
    }
    return -1;
    }




    new WeaponNames[][] = {
    {"Unarmed (Fist)"},{"Brass Knuckles"}, {"Golf Club"}, {"Night Stick"}, {"Knife"}, {"Baseball Bat"}, {"Shovel"}, {"Pool Cue"}, {"Katana"}, {"Chainsaw"},
    {"Purple Dildo"}, {"Big White Vibrator"}, {"Medium White Vibrator"}, {"Small White Vibrator"}, {"Flowers"}, {"Cane"}, {"Grenade"}, {"Teargas"},{"Molotov"},
    {" "},{" "},{" "},{"Colt "},{"Colt (Silenced)"},{"Desert Eagle"},{"Normal Shotgun"},{"Sawnoff Shotgun"},{"Combat Shotgun"}, {"Micro Uzi (Mac )"},
    {"MP"},{"AK"},{"M4"},{"Tec"},{"Country Rifle"},{"Sniper Rifle"},{"Rocket Launcher"},{"Heat-Seeking Rocket Launcher"},{"Flamethrower"}, {"Minigun"},
    {"Satchel Charge"},{"Detonator"},{"Spray Can"},{"Fire Extinguisher"},{"Camera"},{"Night Vision Goggles"},{"Infrared Vision Goggles"},{"Parachute"},{"Fake Pistol"}
    };

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

    Margarete Stokowski

  • do.de - Domain-Offensive - Domains für alle und zu super Preisen