Setting a name for an ID? +rep
#1

I have this dynamic gun system, hard to explain

But say if the gun is equal to ID 24: how can I make it say Deagle instead of 24 on the dialog?

Im sure I have to put it at the top and make it = it or something, not sure

+rep
Reply
#2

Well creat your own stock function
Like ConverWeaponID
which then you have to Do it like this for example:
pawn Код:
Stock ConvertWeaponID(ID)
{
If(ID == 24)
     {
            new Str[10] = "Deagle";
            return Str;
     }
}
Do that for the rest of the ID'S,
The use of it it's simple lets say you need gun ID 30 converted I to name so you do
Код:
new WeaponNameStr[10] = ConvertWeaponID(30);
The code can be shortened or placed in switch(), but this is 1 way of doing it.
EDIT
Use the post bellows method as it saves time/lines.
Forgot about that function
Reply
#3

PHP код:
stock GetWeaponByID(weapon)
{
    new 
string[30];
    
GetWeaponName(weaponstringsizeof(string));
    return 
string;

for example
PHP код:
printf("%s"GetWeaponByID(24)); 
will print out "Desert Eagle"
Reply
#4

Quote:

Weapon_ReturnType(iFac, playerid) {

new
szName[32] = "Undefined Weapon", iFac = arrFaction[playerid][g_iFactionID];

switch(arrFaction[iFac][g_iLockerGuns]) {
case 1: szName = "Brass Knuckles";
case 2: szName = "Golf Club";
case 3: szName = "Nightstick";
case 4: szName = "Knife";
case 5: szName = "Baseball Bat";
case 6: szName = "Shovel";
case 7: szName = "Pool Cue";
case 8: szName = "Katana";
case 9: szName = "Chainsaw";
case 10: szName = "Double-ended Dildo";
}
return szName;
}

would that work?

+ i really dont understand what you both mean?

Its for a locker:
Quote:

format(string, sizeof(string), "%s - Get weapon", Weapon_ReturnType(iFac));
ShowPlayerDialog(playerid, DIALOG_FACWEPS, DIALOG_STYLE_LIST, "Faction Locker", string, "Select", "Cancel");

But whenever I use my function it just says Unknown Command
Reply
#5

pawn Код:
new WeaponNames[47][] =
{
    "Unarmed","BrassKnuckles","Golfclub","Nitestick","Knife","Baseball Bat","Shovel","Poolcue","Katana","Chainsaw","Purple Dildo","Small White Vibrator","Large White Vibrator","Silver Vibrator",
    "Flowers","Cane","Grenade","Tear Gas Grenade","Molotov Cocktail","Jetpack"," "," ","9mm","Silenced 9mm","Deagle","Shotgun","Sawn-Off Shotgun","SPAS-12",
    "MicroUzi","MP5","AK-47","M4","Tec-9","Rifle","Sniper Rifle","RPG","Heatseeker","Flamethrower","Minigun","SatchelCharge","Detonator","SprayCan","Fire Extinguisher",
    "Camera","Nightvision Goggles", "Thermal Goggles","Parachute"
};
Then, when you're checking for the weapon name.

pawn Код:
WeaponNames[*INSERTGENERICID*]
Reply
#6

Use VincentDunn code..
Reply
#7

Quote:
Originally Posted by vIBIENNYx
Посмотреть сообщение
pawn Код:
new WeaponNames[47][] =
{
    "Unarmed","BrassKnuckles","Golfclub","Nitestick","Knife","Baseball Bat","Shovel","Poolcue","Katana","Chainsaw","Purple Dildo","Small White Vibrator","Large White Vibrator","Silver Vibrator",
    "Flowers","Cane","Grenade","Tear Gas Grenade","Molotov Cocktail","Jetpack"," "," ","9mm","Silenced 9mm","Deagle","Shotgun","Sawn-Off Shotgun","SPAS-12",
    "MicroUzi","MP5","AK-47","M4","Tec-9","Rifle","Sniper Rifle","RPG","Heatseeker","Flamethrower","Minigun","SatchelCharge","Detonator","SprayCan","Fire Extinguisher",
    "Camera","Nightvision Goggles", "Thermal Goggles","Parachute"
};
Then, when you're checking for the weapon name.

pawn Код:
WeaponNames[*INSERTGENERICID*]
This worked but how can I get it so when its looking for the name it like urm basically so i dont have to just put in the ID

My code:
Quote:

format(string, sizeof(string), "%s - Get weapon", WeaponNames[4]);
ShowPlayerDialog(playerid, DIALOG_FACWEPS, DIALOG_STYLE_LIST, "Faction Locker", string, "Select", "Cancel");

It worked since its showing a knife but how can I make it so when I set a faction weapon it will go through all the names to match the ID?
Reply
#8

just use this:
saves a lot of lines.
PHP код:
new str[5];GetWeaponName(inputtextstrsizeof(str));
format(stringsizeof(string), "%s - Get weapon"str);
ShowPlayerDialog(playeridDIALOG_FACWEPSDIALOG_STYLE_LIST"Faction Locker"string"Select""Cancel"); 
Reply
#9

Quote:

'error 017: undefined symbol "inputtext"'

Im not using a dialog to set the weapons;


Quote:

CMDetfactionweapons(playerid, params[])
{
new iFac = arrFaction[playerid][g_iFactionID], weapons;
if(arrFaction[playerid][p_iMember] == 12 || arrFaction[playerid][p_iMember] == 11)
{
if(sscanf(params, "d", weapons))
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setfactionweapons [weaponid]");

arrFaction[iFac][g_iLockerGuns] = weapons;
CreateDynamicFaction(weapons);
SendClientMessage(playerid, COLOR_WHITE, "You have changed the weapon ID's for your faction.");
}
else SendClientMessage(playerid, COLOR_WHITE, "You are not authorized to use that command!");
return 1;
}

Quote:

CMD:testlocker(playerid, params[])
{
new string[256], iFac = arrFaction[playerid][g_iFactionID];
if(arrFaction[playerid][p_iMember] > 0)
{
if(arrFaction[iFac][g_iLockerGuns] == 0)
{
SendClientMessage(playerid, COLOR_WHITE, "Your faction lockers have no weapons in them!");
}
if(arrFaction[iFac][g_iLockerGuns] > 0)
{
/*format(string, sizeof(string), "%s - $320", WeaponNames[4]);
ShowPlayerDialog(playerid, DIALOG_FACWEPS, DIALOG_STYLE_LIST, "Faction Locker", string, "Select", "Cancel");*/
new str[5];GetWeaponName(inputtext, str, sizeof(str));
format(string, sizeof(string), "%s - Get weapon", str);
ShowPlayerDialog(playerid, DIALOG_FACWEPS, DIALOG_STYLE_LIST, "Faction Locker", string, "Select", "Cancel");
}
}
else SendClientMessage(playerid, COLOR_WHITE, "You are not in a faction!");
return 1;
}

so any help on dis
Reply
#10

PHP код:
CMD:testlocker(playeridparams[])
{
new 
string[256], iFac arrFaction[playerid][g_iFactionID];
if(
arrFaction[playerid][p_iMember] > 0)
{
if(
arrFaction[iFac][g_iLockerGuns] == 0)
{
SendClientMessage(playeridCOLOR_WHITE"Your faction lockers have no weapons in them!");
}
if(
arrFaction[iFac][g_iLockerGuns] > 0)
{
new 
str[5];GetWeaponName(arrFaction[iFac][g_iLockerGuns], strsizeof(str));
format(stringsizeof(string), "%s - Get weapon"str);
ShowPlayerDialog(playeridDIALOG_FACWEPSDIALOG_STYLE_LIST"Faction Locker"string"Select""Cancel");
}
}
else 
SendClientMessage(playeridCOLOR_WHITE"You are not in a faction!");
return 
1;

i dont know what variable your using
i think is this arrFaction[iFac][g_iLockerGuns] ?
so try the code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)