Simple sscanf problem. showing weird id
#1

Hey guys. So, I got this problem now. I made a simple command which lets people give other people weapons. The problem is that whenever this happens, the script is supposed to sendclientmessage to both playerid and targetid that what weapon id they got, and stuff like that(see simple code for examples). instead of the code writing something like "you got weaponn 24 with 100 bullets', it says something like "you got weapon 2398472934723 with 12931202914" bullets.
Thank you

Код:
CMD:giveweapon(playerid,params[])
{
		new targetid,weaponid,bullets;
		if(sscanf(params,"iii",targetid,weaponid,bullets))
		{
			  return SendClientMessage(playerid,COLOR_RED,"usage: /giveweapon [playerid] [weaponid] [bullets]");
        }
        if(!IsPlayerConnected(targetid))
        {
			  return SendClientMessage(playerid,COLOR_RED,"Invalid playerid.");
        }
        if(weaponid<1||weaponid>46)
        {
			  return SendClientMessage(playerid,COLOR_RED,"Invalid weapon id.");
        }
        if(bullets<1||bullets>1000)
        {
			  return SendClientMessage(playerid,COLOR_RED,"Invalid number of bullets. Max: 1000.");
        }
        GivePlayerWeapon(targetid,weaponid,bullets);
        SendClientMessage(playerid,COLOR_GREEN,"You have given %i weapon with id %i and %i bullets.",targetid,weaponid,bullets);
        SendClientMessage(targetid,COLOR_GREEN,"You have recieved weapon id %i with %i bullets.",weaponid,bullets);
        return 1;
}
Reply
#2

pawn Код:
if(sscanf(params,"uii",targetid,weaponid,bullets))
Reply
#3

Didn't help at all. Thanks for the effort, though
Reply
#4

pawn Код:
CMD:givegun(playerid, params[])
{
    new playerb, gunid, ammo, string[128];
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You are not authorized to use this command.");
    if(sscanf(params, "uii", playerb, gunid, ammo))
    {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givegun [playerid] [gunid] [ammo]");
        SendClientMessage(playerid, COLOR_GREEN, "_______________________________________");
        SendClientMessage(playerid, COLOR_GREY, "1: Brass Knuckles 2: Golf Club 3: Nite Stick 4: Knife 5: Baseball Bat 6: Shovel 7: Pool Cue 8: Katana 9: Chainsaw");
        SendClientMessage(playerid, COLOR_GREY, "10: Purple Dildo 11: Small White Vibrator 12: Large White Vibrator 13: Silver Vibrator 14: Flowers 15: Cane 16: Frag Grenade");
        SendClientMessage(playerid, COLOR_GREY, "17: Tear Gas 18: Molotov Cocktail 19: Vehicle Missile 20: Hydra Flare 21: Jetpack 22: 9mm 23: Silenced 9mm 24: Desert Eagle 25: Shotgun");
        SendClientMessage(playerid, COLOR_GREY, "26: Sawnoff Shotgun 27: SPAS-12 28: Micro SMG (Mac 10) 29: SMG (MP5) 30: AK-47 31: M4 32: Tec9 33: Rifle");
        SendClientMessage(playerid, COLOR_GREY, "25: Shotgun 34: Sniper Rifle 35: Rocket Launcher 36: HS Rocket Launcher 37: Flamethrower 38: Minigun 39: Satchel Charge");
        SendClientMessage(playerid, COLOR_GREY, "40: Detonator 41: Spraycan 42: Fire Extinguisher 43: Camera 44: Nightvision Goggles 45: Infared Goggles 46: Parachute");
        SendClientMessage(playerid, COLOR_GREEN, "_______________________________________");

        return 1;
    }
    if(gunid < 0 || gunid > 46 || gunid == 19 || gunid == 20 || gunid == 21) return SendClientMessage(playerid, COLOR_GREY, "Invalid weapon id.");
    GivePlayerWeapon(playerb, gunid, ammo);
    format(string, sizeof(string), " You have given %s a %s with %d ammo.", RPNU(playerb), RWN(gunid), ammo);
    SendClientMessage(playerid, COLOR_WHITE, string);
    format(string, sizeof(string), " Administrator %s has given you a %s with %d ammo.", RPNU(playerid), RWN(gunid), ammo);
    SendClientMessage(playerb, COLOR_WHITE, string);
    return 1;
}

#define COLOR_GREEN 0x00820FAA
#define COLOR_GREY 0xAFAFAFFF
#define COLOR_WHITE 0xFFFFFFFF

stock RWN(weaponid)
{
    new name[32];
    GetWeaponName(weaponid, name, sizeof(name));
    if(weaponid == 0) format(name, sizeof(name), "None");
    return name;
}

stock RPNU(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Reply
#5

there you go
pawn Код:
CMD:giveweapon(playerid,params[])
{
        new targetid,weaponid,bullets;
        if(sscanf(params,"iii",targetid,weaponid,bullets))
        {
              return SendClientMessage(playerid,COLOR_RED,"usage: /giveweapon [playerid] [weaponid] [bullets]");
        }
        if(!IsPlayerConnected(targetid))
        {
              return SendClientMessage(playerid,COLOR_RED,"Invalid playerid.");
        }
        if(weaponid<1||weaponid>46)
        {
              return SendClientMessage(playerid,COLOR_RED,"Invalid weapon id.");
        }
        if(bullets<1||bullets>1000)
        {
              return SendClientMessage(playerid,COLOR_RED,"Invalid number of bullets. Max: 1000.");
        }
        GivePlayerWeapon(targetid,weaponid,bullets);
        SendClientMessage(playerid,COLOR_GREEN,"You have given %d weapon with id %d and %d bullets.",targetid,weaponid,bullets);
        SendClientMessage(targetid,COLOR_GREEN,"You have recieved weapon id %d with %d bullets.",weaponid,bullets);
        return 1;
}
The formatting is wrong!
Dont use %i in this case, here you use %d
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)