problem with /giveweapon name
#1

Its not working,shows unknown command

Код:
CMD:giveweapon(playerid,params[])
{
    new string[256],id,weapon,Weapon[50],pAmmo,pName[MAX_PLAYER_NAME],pName1[MAX_PLAYER_NAME];
    if(PInfo[playerid][Level] < 3)
    return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 3 to give someone weapons.");
    if(sscanf(params,"us[50]d",id,weapon,pAmmo))
	return SendClientMessage(playerid,STEALTH_BLUE,"USAGE: /giveweapon [id] [weapon] [ammo]");
 if(!IsPlayerConnected(id))
	return SendClientMessage(playerid,STEALTH_BLUE,"That player is not connected!");
	weapon = GetWeaponModelIDFromName(Weapon);
    if(weapon < 0 || weapon > 46 || weapon == 19 || weapon == 20 || weapon == 21 || weapon == 22)
    return SendClientMessage(playerid, COLOR_INDIANRED,"This is not a valid weapon name! PLease try again");
    GivePlayerWeapon(id,weapon,pAmmo);
	GetPlayerName(playerid,pName,sizeof pName);
	format(string,sizeof(string),"Administrator %s has given you %s with %d ammo.",pName,WeaponNames[weapon],pAmmo);
    SendClientMessage(playerid,COLOR_DARKORCHID,string);
	GetPlayerName(id,pName1,sizeof pName1);
	format(string,sizeof(string),"You have given %s %s with %d ammo.",pName1,WeaponNames[weapon],pAmmo);
	SendClientMessage(playerid,COLOR_DARKORCHID,string);
	CMDMessageToAdmins(playerid,"GIVEWEAPON");
	return 1;
}
Код:
stock GetWeaponModelIDFromName(wname[])
{
    for(new i = 0; i < 48; i++) {
        if (i == 19 || i == 20 || i == 21) continue;
        if (strfind(WeaponNames[i], wname, true) != -1) {
        return i;
        }
    }
    return -1;
}
Reply
#2

Write it like this:

Код:
CMD:giveweapon(playerid,params[])
{
    new string[128],id,weapon,pAmmo,pName[MAX_PLAYER_NAME];
    if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 3 to give someone weapons.");
    if(sscanf(params,"udd",id,weapon,pAmmo)) return SendClientMessage(playerid,STEALTH_BLUE,"USAGE: /giveweapon [id] [weapon] [ammo]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,STEALTH_BLUE,"That player is not connected!");
    if(weapon < 0 || weapon > 46 || weapon == 19 || weapon == 20 || weapon == 21 || weapon == 22) return SendClientMessage(playerid, COLOR_INDIANRED,"This is not a valid weapon name! PLease try again");
    GivePlayerWeapon(id,weapon,pAmmo),GetPlayerName(playerid,pName,sizeof pName);
    format(string,sizeof(string),"Administrator %s has given you %s with %d ammo.",pName,WeaponNames[weapon],pAmmo);
    SendClientMessage(playerid,COLOR_DARKORCHID,string),GetPlayerName(id,pName,sizeof pName);
    format(string,sizeof(string),"You have given %s %s with %d ammo.",pName,WeaponNames[weapon],pAmmo);
    SendClientMessage(playerid,COLOR_DARKORCHID,string),CMDMessageToAdmins(playerid,"GIVEWEAPON");
    return 1;
}
Greekz
Reply
#3

Ah its not working when i use /giveweapon 0 eagle 500 it shows me parameters..
Reply
#4

Quote:
Originally Posted by Nabster
Посмотреть сообщение
Ah its not working when i use /giveweapon 0 eagle 500 it shows me parameters..
Yeah, eagle is 24...i made it without name, just use an id:

Код:
/giveweapon 0 24 500
Just make you a short list, where you show yourself, what id is what name

You find it here: https://sampwiki.blast.hk/wiki/Weapons
Reply
#5

I am actually creating it with name parameter

this are my codes

Код:
new WeaponNames[47][] =
{
        {"Unarmed"},{"Brass Knuckles"},{"Golf Club"},{"Nite Stick"},{"Knife"},{"Baseball Bat"},{"Shovel"},{"Pool Cue"},{"Katana"},{"Chainsaw"},{"Purple Dildo"},
        {"Smal White Vibrator"},{"Large White Vibrator"},{"Silver Vibrator"},{"Flowers"},{"Cane"},{"Grenade"},{"Tear Gas"},{"Molotov Cocktail"},
        {""},{""},{""}, // Empty spots for ID 19-20-21 (invalid weapon id's)
        {"9mm"},{"Silenced 9mm"},{"Desert Eagle"},{"Shotgun"},{"Sawn-off Shotgun"},{"Combat Shotgun"},{"Micro SMG"},{"MP5"},{"AK-47"},{"M4"},{"Tec9"},
        {"Country Rifle"},{"Sniper Rifle"},{"Rocket Launcher"},{"HS Rocket Launcher"},{"Flamethrower"},{"Minigun"},{"Satchel Charge"},{"Detonator"},
        {"Spraycan"},{"Fire Extinguisher"},{"Camera"},{"Nightvision Goggles"},{"Thermal Goggles"},{"Parachute"}
};
Код:
stock GetWeaponModelIDFromName(wname[])
{
    for(new i = 0; i < 48; i++) {
        if (i == 19 || i == 20 || i == 21) continue;
        if (strfind(WeaponNames[i], wname, true) != -1) {
        return i;
        }
    }
    return -0;
}
Reply
#6

Quote:
Originally Posted by Nabster
Посмотреть сообщение
I am actually creating it with name parameter
No...look at my code.

Just make sth like this:

Код:
CMD:giveweapon(playerid,params[])
{
    new string[128],id,weapon,pAmmo,pName[MAX_PLAYER_NAME];
    if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 3 to give someone weapons.");
    if(sscanf(params,"udd",id,weapon,pAmmo)) return SendClientMessage(playerid,STEALTH_BLUE,"USAGE: /giveweapon [id] [weaponid] [ammo]"),PostWeaponList(playerid);
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,STEALTH_BLUE,"That player is not connected!");
    if(weapon <= 0 || weapon > 46 || weapon == 19 || weapon == 20 || weapon == 21 || weapon == 22) return SendClientMessage(playerid, COLOR_INDIANRED,"This is not a valid weapon name! PLease try again");
    GivePlayerWeapon(id,weapon,pAmmo),GetPlayerName(playerid,pName,sizeof pName);
    format(string,sizeof(string),"Administrator %s has given you %s with %d ammo.",pName,WeaponNames[weapon],pAmmo);
    SendClientMessage(playerid,COLOR_DARKORCHID,string),GetPlayerName(id,pName,sizeof pName);
    format(string,sizeof(string),"You have given %s %s with %d ammo.",pName,WeaponNames[weapon],pAmmo);
    SendClientMessage(playerid,COLOR_DARKORCHID,string),CMDMessageToAdmins(playerid,"GIVEWEAPON");
    return 1;
}

stock PostWeaponList(playerid) {
    SendClientMessage(playerid,-1,"Possible weaponids:");
    for(new i=1,tmp[64]; i<47; i++) {
        if (i == 19 || i == 20 || i == 21) continue;
        format(tmp,64,"weaponid: %d | Name: %s",i,WeaponNames[i]);
        SendClientMessage(playerid,-1,tmp);
    }
    return 1;
}
And the Command you press InGame is:

Код:
/giveweapon 0 24 500

/*
Instead of using eagle, press 24 (the WEAPONID)
*/
Greekz
Reply
#7

lol dude,you didn't understand what i am making,i already made it with using /giveweapon 0 24 500 but now i am creating to giveweapon with name not ID's

anyways fixed myself
Reply
#8

Код:
if(sscanf(params,"us[50]d",id,weapon,pAmmo))
Код:
if(sscanf(params,"us[50]d",id,Weapon,pAmmo)) //'W' Uppercase
Reply
#9

Take this....
PHP код:
stock GetWName(wid)
{
    new 
weaponname[20];
    
GetWeaponName(widweaponnamesizeof(weaponname));
    return 
weaponname;

Reply
#10

Quote:
Originally Posted by bondowocopz
Посмотреть сообщение
Код:
if(sscanf(params,"us[50]d",id,weapon,pAmmo))
Код:
if(sscanf(params,"us[50]d",id,Weapon,pAmmo)) //'W' Uppercase
yeah already fixed,ty
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)