/giveweapon command outputs player name instead of weapon name...
#1

hey all,

i made this /giveweapon command, but somehow it says: Administrator ApenMeeuw has given you a ApenMeeuw... instead of Administrator ApenMeeuw has given you a Tec-9, for example..


pawn Код:
CMD:giveweapon(playerid, params[])
{
    if(IsPlayerNAdminLevel(playerid, LEVEL_GIVEWEAPON))
    {
        new targetid, WeapName[34], Weap[34];
        if(sscanf(params, "us[34]", targetid, WeapName)) return UsageMessage(playerid, "giveweapon", "[playerid]", "[weaponname]", "");
        if(targetid == INVALID_PLAYER_ID) return InvPid(playerid);
        SendCommandToAdmins(playerid, "giveweapon");
        GivePlayerWeapon(targetid, GetWeaponIDFromName(WeapName), 5000);
        new string[128];
        format(string, sizeof(string), "Administrator {FFFFFF}%s(%d) "EMBED_ARASIA"has given you a {FFFFFF}%s", PlayersName(playerid), playerid, GetWeaponName(GetWeaponIDFromName(WeapName),Weap,32));
        SendClientMessage(targetid, COLOR_ARASIA, string);
        format(string, sizeof(string), "You have given {FFFFFF}%s(%d) "EMBED_ARASIA"a {FFFFFF}%s", PlayersName(targetid), targetid, GetWeaponName(GetWeaponIDFromName(WeapName),Weap,32));
        SendClientMessage(playerid, COLOR_ARASIA, string);
    }
    else return ErrorMessage(playerid, LEVEL_GIVEWEAPON);
    return 1;
}
whats wrong with that?

the GetWeaponIDFromName:
pawn Код:
stock GetWeaponIDFromName(WeaponName[])
{
    if(strfind("molotov",WeaponName,true)!=-1)
    return 18;
    for(new i = 0; i <= 46; i++)
    {
    switch(i)
    {
    case 0,19,20,21,44,45: continue;
    default:
    {
    new name[32]; GetWeaponName(i,name,32);
    if(strfind(name,WeaponName,true) != -1)
    return i;
    }
    }
    }
    return -1;
}

whats wrong with this code?

greets
Reply
#2

Try it

pawn Код:
CMD:giveweapon(playerid, params[])
{
    if(IsPlayerNAdminLevel(playerid, LEVEL_GIVEWEAPON))
    {
        new targetid, WeapName[34], Weap[34];
        if(sscanf(params, "us[34]", targetid, WeapName)) return UsageMessage(playerid, "giveweapon", "[playerid]", "[weaponname]", "");
        if(targetid == INVALID_PLAYER_ID) return InvPid(playerid);
        SendCommandToAdmins(playerid, "giveweapon");
        new weapid = GetWeaponIDFromName(WeapName);
        GivePlayerWeapon(targetid, weapid, 5000);
        GetWeaponName(weapid,Weap,32);
        new string[128];
        format(string, sizeof(string), "Administrator {FFFFFF}%s(%d) "EMBED_ARASIA"has given you a {FFFFFF}%s", PlayersName(playerid), playerid, Weap);
        SendClientMessage(targetid, COLOR_ARASIA, string);
        format(string, sizeof(string), "You have given {FFFFFF}%s(%d) "EMBED_ARASIA"a {FFFFFF}%s", PlayersName(targetid), targetid, Weap);
        SendClientMessage(playerid, COLOR_ARASIA, string);
    }
    else return ErrorMessage(playerid, LEVEL_GIVEWEAPON);
    return 1;
}
Reply
#3

it works thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)