Share ammo problem
#1

This command works perfectly except a thing, it shows everytime "Fist" as weapon name:

pawn Код:
CMD:sammo(playerid, params[])
{
    if(pInfo[playerid][Logged] == 0) return SCM(playerid,0x0080C0FF,"Please login before using this command.");
    if(pInfo[playerid][Jailed] == 1) return SCM(playerid,0xFF0000FF,"You can't use this command in jail.");
    if(pSpawned[playerid] == 0) return SCM(playerid, COLOR_LIGHTBLUE, "Please spawn before doing any action.");
    if(pAlive[playerid] == 0) return SCM(playerid, COLOR_LIGHTBLUE, "You can't use this command if you are dead.");
    new pID, value;
    new weap;
    GetPlayerWeaponData(playerid, 7, weap,value);
    if(sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, -1, "{F70505}Usage: {FFFFFF}/sammo <playerid> <ammo ammount>");
    else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "Invalid id.");
    else if(value > GetPlayerAmmo(playerid)) return SendClientMessage(playerid, red, "Your ammo ammount aren't enough to share with.");
    //else if(pID == playerid) return SendClientMessage(playerid, red, "You can't share ammo with yourself.");
    else if(GetPlayerWeapon(pID) != GetPlayerWeapon(playerid)) return SendClientMessage(playerid, red, "The player needs to have the same gun as you are having.");
    else
    {
        new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        GetPlayerName(pID, tName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "** You shared %i ammo of your %s to %s (%d)", value,GetWeaponNameByID(weap),tName,pID);
        SendClientMessage(playerid, COLOR_CON_GREEN, string);
        format(string, sizeof(string), "** You got %i ammo of %s by %s (%d)", value,GetWeaponNameByID(weap),pName,playerid);
        SendClientMessage(pID, COLOR_CON_GREEN, string);
        SetPlayerAmmo(pID, GetPlayerWeapon(pID), GetPlayerAmmo(pID)+value);
        SetPlayerAmmo(pID, GetPlayerWeapon(playerid), GetPlayerAmmo(playerid)-value);
        new echo[250];
        format(echo, sizeof(echo), "02,3** %s (%d) has shared %i ammo of %s (wid %d) with %s (%d)", pName,playerid,value,GetWeaponNameByID(weap),weap,tName,pID);
        IRC_GroupSay(gGroupID, IRC_CHANNEL, echo);
        IRC_GroupSay(gGroupID, IRC_ACHANNEL, echo);
    }
    return 1;
}
GetWeaponNameById stock:

pawn Код:
stock GetWeaponNameByID(wid)
{
    new gunname[32];
    switch (wid)
    {
        case    1 .. 17,
                22 .. 43,
                46 :        GetWeaponName(wid,gunname,sizeof(gunname));
        case    0:          format(gunname,32,"%s","Fist");
        case    18:         format(gunname,32,"%s","Molotov Cocktail");
        case    44:         format(gunname,32,"%s","Night Vis Goggles");
        case    45:         format(gunname,32,"%s","Thermal Goggles");
        default:            format(gunname,32,"%s","Invalid Weapon Id");

    }
    return gunname;
}
What's wrong?
Reply
#2

Bump.
Reply
#3

You have not given 'weap' a value...
pawn Код:
new weap;
Without actually giving it a value, it's value is 0 by default upon creation. So you are passing as GetPlayerWeaponNameFromId(0), Weapon ID 0 being 'Fist'.
I trust you will be able to fix it yourself, otherwise I can help you out.
Reply
#4

new weap[32]; ?

I dont use this on my normal anticheat but it works. Just in this command i get the "Fist" message...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)