AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   error in client print (https://forums.alliedmods.net/showthread.php?t=320790)

Sanjay Singh 01-09-2020 11:16

error in client print
 
first one causing error whats wrong?

PHP Code:

if(is_xp_loaded)
client_print_color(id0"Your Rank: %i %s"getrank(id), is_xp_loaded "XP: %i"getxp(id) : "")
else
client_print_color(id0"Your Rank: %i"getrank(id)) 


OciXCrom 01-09-2020 13:28

Re: error in client print
 
If you get an error, you post the error here...

You can't pass multiple arguments in a ternary check.

PHP Code:

is_xp_loaded "XP: %i"getxp(id) : "" 

Simply use an if-else check.

JocAnis 01-09-2020 14:31

Re: error in client print
 
Quote:

Originally Posted by OciXCrom (Post 2679538)
You can't pass multiple arguments in a ternary check.

PHP Code:

is_xp_loaded "XP: %i"getxp(id) : "" 


is there any possibility this can be implemented in new amxx version? 1.10 or which ever is next prepared

because its really faster that way to use it, alteast from my experience

OciXCrom 01-09-2020 15:01

Re: error in client print
 
You can use "fmt" in 1.10.

PHP Code:

is_xp_loaded fmt("XP: %i"getxp(id)) : "" 


Sanjay Singh 01-09-2020 16:06

Re: error in client print
 
Quote:

Originally Posted by OciXCrom (Post 2679557)
You can use "fmt" in 1.10.

PHP Code:

is_xp_loaded fmt("XP: %i"getxp(id)) : "" 


And in 1.8.2?

OciXCrom 01-09-2020 20:51

Re: error in client print
 
if and else ._.

fysiks 01-09-2020 22:04

Re: error in client print
 
Just always format the "XP: %i" and then conditionally use the string with the ternary operator. Simple.

Sanjay Singh 01-10-2020 02:48

Re: error in client print
 
Quote:

Originally Posted by fysiks (Post 2679595)
Just always format the "XP: %i" and then conditionally use the string with the ternary operator. Simple.

PHP Code:

new playerxp[64]
formatex(playerxpcharmax(playerxp) , "XP : %i"getxp(I'd))

is_xp_loaded ? playerxp : "" 

Ignore syntax mistake used phone to write code 😂

OciXCrom 01-10-2020 07:25

Re: error in client print
 
Yes, that will work.

PS: you probably don't need to store 64 characters in there.

georgik57 01-11-2020 10:51

Re: error in client print
 
Quote:

Originally Posted by Sanjay Singh (Post 2679523)
PHP Code:

if([B]is_xp_loaded[/B])
client_print_color(id0"Your Rank: %i %s"getrank(id), [B]is_xp_loaded[/B] ? "XP: %i"getxp(id) : ""


Why are you checking it twice tho?


All times are GMT -4. The time now is 02:43.

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