AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   A little bit help with '?' (https://forums.alliedmods.net/showthread.php?t=217431)

~Ice*shOt 06-02-2013 15:58

A little bit help with '?'
 
PHP Code:

  show_hudmessage(id"Points %s"Points[id] <= "will be reseted" "[%d]"Points[id]) 

Works in this way:
if points < or = than 0 shows Points [%d] (why %d don't converts to Points[id]?)
Who can fix this?

^SmileY 06-02-2013 16:12

Re: A little bit help with '?'
 
PHP Code:

show_hudmessage(id, (!Points[id]) ? "Points will be reseted." "Points [%d]"Points[id]); 

I don't see any other way to put this in an function

>> (!Points[id]) Always return true if the points its equal or < 0 :)

Remember:

PHP Code:

(CONDITION) ? TRUE FALSE 


~Ice*shOt 06-02-2013 16:35

Re: A little bit help with '?'
 
PHP Code:

show_hudmessage(idPoints[id] <= "Points will be reseted" "Points [%d]"Points[id]) 

works correctly in this way, thanks.

TheDS1337 06-02-2013 17:07

Re: A little bit help with '?'
 
you can use if and else instead of this:
Code:

if( Points[ id ] < 1 )
        show_hudmessage( id, "Points will be reseted" );
else
        show_hudmessage( id, "Points [%d]", Points[ id ] );


fysiks 06-03-2013 00:32

Re: A little bit help with '?'
 
Quote:

Originally Posted by ~Ice*shOt (Post 1963244)
PHP Code:

  show_hudmessage(id"Points %s"Points[id] <= "will be reseted" "[%d]"Points[id]) 

Works in this way:
if points < or = than 0 shows Points [%d] (why %d don't converts to Points[id]?)
Who can fix this?

That doesn't work because the formatting only occurs once and for it to work this way it would need to run twice.

ConnorMcLeod 06-03-2013 01:00

Re: A little bit help with '?'
 
If you want to make sure you don't print negative values (shouldn't happen with a decent code...), use max(0, Points[id]) as last argument.

MPNumB 06-03-2013 17:16

Re: A little bit help with '?'
 
Quote:

Originally Posted by ^SmileY (Post 1963250)

>> (!Points[id]) Always return true if the points its equal or < 0 :)

Actually in that case only if it's 0.

PHP Code:

new iVariable 0;
if( !
iVariable )
 
client_print(0print_chat"passed, since (!0 == true)");

new 
iVariable 1;
if( !
iVariable )
 
client_print(0print_chat"didn't pass, since (!1 == false)");

new 
iVariable = -1;
if( !
iVariable )
 
client_print(0print_chat"didn't pass, since (!-1 == false)"); 

// Only if( 0 ) function will not pass, in other conditions it always passes. In other words, only 0 is false, everything else is considered as true. (At least in my experience).

^SmileY 06-03-2013 17:58

Re: A little bit help with '?'
 
Omg, its in case of '?' condition...

Like

PHP Code:

(!Variable) ? TRUE FALSE 

LOL


All times are GMT -4. The time now is 16:24.

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