AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED]%d, s and so on help (https://forums.alliedmods.net/showthread.php?t=208860)

Unkolix 02-18-2013 07:03

[SOLVED]%d, s and so on help
 
I would like to know if I am doing it right... I tried %s and %d...
PHP Code:

ItemChoise M4A1
client_print
idprint_center"%L"id"CHOSE_M4A1"ItemChoise ); 

Code:

CHOSE_M4A1 = You succesfully got %d!

AngeIII 02-18-2013 07:18

Re: %d, s and so on help
 
the problem can be here:
ItemChoise = M4A1

if ItemChoise are integer-number use %d
if itemchoise are string(chars array) use %s

also what is M4A1 -> ?? variable or string? if you wan't it to string do like this:

new ItemChoise[] = "M4A1";
and use %s


hornet 02-18-2013 07:20

Re: %d, s and so on help
 
Doesn't this seem more appropriate:

PHP Code:

new szWeapon32 ];
get_weaponnameItemChoiseszWeaponcharsmaxszWeapon ) );
    
client_printidprint_center"%L"LANG_SERVER"WEAPON_CHOOSE"szWeapon ); 

Code:

WEAPON_CHOOSE = You succesfully got %s!

Unkolix 02-18-2013 07:39

Re: %d, s and so on help
 
Quote:

Originally Posted by AngeIII (Post 1896792)
the problem can be here:
ItemChoise = M4A1

if ItemChoise are integer-number use %d
if itemchoise are string(chars array) use %s

also what is M4A1 -> ?? variable or string? if you wan't it to string do like this:

new ItemChoise[] = "M4A1";
and use %s


You see, I have another menu after that one, and if player chose M4A1, next he must choose from primary guns and when he does so, he should get a message like this
Code:

CHOSE_DEAGLE = You succesfully got %s with Deagle!
BTW, your code seems to be bad because I get that
Code:

Invalid subscript(not an array or too many subscripts)
Maybe more code would help you understand?
PHP Code:

case 1
{              
    
StripWeapons(idPrimary);
    
give_item(id,"weapon_m4a1"//Gives VIP M4A1
    
cs_set_user_bpammo(idCSW_M4A190); //Sets VIP M4A1 back pack ammo to 90
    
ItemChoise[] = "M4A1"
    
client_printidprint_center"%L"id"CHOSE_M4A1"ItemChoise );
    
gbMenuUsed[id] = true//Makes sure that VIP really made a choise
}
/***/
case 1
{                      
    
StripWeapons(idSecondary);
    
give_item(id,"weapon_deagle"//Gives VIP Deagle
    
cs_set_user_bpammo(idCSW_DEAGLE35); //Sets VIP Deagle back pack ammo to 35
    
client_printidprint_center"%L"id"CHOSE_DEAGLE"ItemChoise );


Code:

CHOSE_M4A1 = You succesfully got %d!
CHOSE_DEAGLE = You succesfully got %s with Deagle!


hornet 02-18-2013 08:29

Re: %d, s and so on help
 
Use my concept, but create an array for weapon names ... dunno what made me come to using get_weaponname() lol ...

Unkolix 02-18-2013 09:17

Re: %d, s and so on help
 
Can you create that array? I don't quite understand you :/

EDUTz 02-18-2013 20:41

Re: %d, s and so on help
 
Code:

new const PRIMARY_NAMES[][] =
{
        "M4A1",
        "AK47",
        "MP5NAVY",
        "G3SG1",
        "AWP"

}

Code:

public mostrar_cliente(id, menu, item)
{
        new data[6], iName[64]
        new access, callback
        menu_item_getinfo(menu, item, access, data,7, iName, 63, callback)
        new key = str_to_num(data)
        client_print(id, print_chat, "%L ^"%s^"", id, "CHOOSE_WEAPON", PRIMARY_NAMES[key])

ML language: CHOOSE_WEAPON = You have chosen

Unkolix 02-19-2013 04:29

Re: %d, s and so on help
 
Shouldn't I add this code
PHP Code:

client_print(idprint_chat"%L ^"%s^""id"CHOOSE_WEAPON"PRIMARY_NAMES[key]) 

in switch cases?

And maybe this? ML language: CHOOSE_WEAPON = You have chosen %d!

hornet 02-19-2013 06:30

Re: %d, s and so on help
 
Quote:

Originally Posted by Unkolix (Post 1897479)
And maybe this? ML language: CHOOSE_WEAPON = You have chosen %d!

No, %d and %i are for integers, not strings.

Unkolix 02-19-2013 06:33

Re: %d, s and so on help
 
Ok, thanks.


All times are GMT -4. The time now is 21:36.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.