Raised This Month: $ Target: $400
 0% 

A little bit help with '?'


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 06-02-2013 , 15:58   A little bit help with '?'
Reply With Quote #1

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?
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-02-2013 , 16:12   Re: A little bit help with '?'
Reply With Quote #2

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 
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 06-02-2013 at 16:17. Reason: Oops
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 06-02-2013 , 16:35   Re: A little bit help with '?'
Reply With Quote #3

PHP Code:
show_hudmessage(idPoints[id] <= "Points will be reseted" "Points [%d]"Points[id]) 
works correctly in this way, thanks.
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
MPNumB
Veteran Member
Join Date: Feb 2007
Location: Lithuania
Old 06-03-2013 , 17:16   Re: A little bit help with '?'
Reply With Quote #4

Quote:
Originally Posted by ^SmileY View Post

>> (!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).
__________________
Skill and no annoying bugs with fixed balance issues is my goal!
My approved plugins what don't show up in Approved List:
* Bomb/Death/CSS Radar
* HotVision
___
Need help? Please check this documentation first.

Last edited by MPNumB; 06-03-2013 at 17:17.
MPNumB is offline
Send a message via Skype™ to MPNumB
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 06-02-2013 , 17:07   Re: A little bit help with '?'
Reply With Quote #5

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 ] );
TheDS1337 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-03-2013 , 00:32   Re: A little bit help with '?'
Reply With Quote #6

Quote:
Originally Posted by ~Ice*shOt View Post
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.
__________________
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-03-2013 , 01:00   Re: A little bit help with '?'
Reply With Quote #7

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.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-03-2013 , 17:58   Re: A little bit help with '?'
Reply With Quote #8

Omg, its in case of '?' condition...

Like

PHP Code:
(!Variable) ? TRUE FALSE 
LOL
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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