cmd no work
#1

this cmd doesnt work:
Код:
CMD:gun(playerid, params[])
{
	new gunid;
	if(sscanf(params,"d",gunid)) return SendClientMessage(playerid, -1, "USAGE: /gun [gunid]");
	GivePlayerWeapon(playerid, gunid, 1000);
	return 1;
}
what i do wrong?
Reply
#2

Try this:
pawn Код:
CMD: gun (playerid, params [])
{
    new gunid[2];
    if (sscanf (params, "d[2]", gunid)) return SendClientMessage (playerid, -1, "USAGE: / gun [gunid]");
    GivePlayerWeapon (playerid, gunid, 1000);
    return 1;
}
Reply
#3

Advanced one >>
pawn Код:
CMD:gun(playerid,params[])
{
new WeaponName[50];
if(sscanf(params,"s[50]"WeaponName))  return SendClientMessage(playerid, -1, "[USAGE] /Gun [Gun-Name]");
GivePlayerWeapon(playerid, GetWeaponModelIDFromName(WeaponName), 10000);
return 1;
}
And add this.
pawn Код:
stock GetWeaponModelIDFromName(wname[])
{
    for(new i = 0; i < 48; i++) {
        if (i == 19 || i == 20 || i == 21) continue;
        if (strfind(aWeaponNames[i], wname, true) != -1) {
            return i;
        }
    }
    return -1;
}
Reply
#4

it looks like someone is posting without knowing what he's doing...
now, what error does the message return? also does it happen with every command? do you have any filterscripts that use strcmp to handle commands? I'm asking because that command is perfect.

Quote:
Originally Posted by Littlehelper[MDZ]
Посмотреть сообщение
Advanced one >>
pawn Код:
CMD:gun(playerid,params[])
{
new WeaponName[50];
if(sscanf(params,"s[50]"WeaponName))  return SendClientMessage(playerid, -1, "[USAGE] /Gun [Gun-Name]");
GivePlayerWeapon(playerid, GetWeaponModelIDFromName(WeaponName), 10000);
return 1;
}
And add this.
pawn Код:
stock GetWeaponModelIDFromName(wname[])
{
    for(new i = 0; i < 48; i++) {
        if (i == 19 || i == 20 || i == 21) continue;
        if (strfind(aWeaponNames[i], wname, true) != -1) {
            return i;
        }
    }
    return -1;
}
tell me how this does answer his question..
also "undefined symbol "aWeaponNames"".
Reply
#5

pawn Код:
// Also add this
new aWeaponNames[][32] =
{
    {"Unarmed"}, {"BrassKnuckles"}, {"GolfClub"}, {"NightStick"}, {"Knife"}, {"BaseballBat"},
    {"Shovel"}, {"PoolCue"}, {"Katana"}, {"Chainsaw"}, {"PurpleDildo"}, {"BigWhiteVibrator"},
    {"MedWhiteVibrator"}, {"SmlWhiteVibrator"}, {"Flowers"}, {"Cane"}, {"Grenade"}, {"Teargas"},
    {"Molotov"}, {"Empty Slot 1"}, {"Empty Slot 2"}, {"Empty Slot 3"}{"Colt45"}, {"SDPistol"},
    {"DesertEagle"}, {"Shotgun"}, {"SawnoffShotgun"}, {"Spas12"}, {"Mac10"},
    {"MP5"}, {"AK47"}, {"M4"}, {"Tec9"}, {"CountryRifle"}, {"Sniper"}, {"RPG"},
    {"HeatRPG"}, {"Flamethrower"}, {"Minigun"}, {"Satchel"}, {"Detonator"},
    {"SprayCan"}, {"Extinguisher"}, {"Camera"}, {"NVGoggles"}, {"IRGoggles"},
    {"Parachute"}, {"Fake Pistol"}
};
forgot the whole code, online by iPhone atm.
EDIT: i just gave him a advanced version of his cmd.
it would be pain in the ass to know the right Weapon id's maybe.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)