Raised This Month: $ Target: $400
 0% 

Whats wrong with this code ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Awesome_man
Senior Member
Join Date: May 2014
Location: singapore
Old 05-04-2016 , 10:34   Whats wrong with this code ?
Reply With Quote #1

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>

#define PLUGIN ""
#define VERSION "1.0"
#define AUTHOR ""



public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
}


public 
client_putinserver(id)
{
    if(!
is_user_connected(id))
    {
        return 
PLUGIN_HANDLED
    
}
    
    new 
time get_user_time(id,1);
    if(
time/60 240)
    {
        return 
PLUGIN_HANDLED
    

    
    if(
time/60 == 30)
    {
        
cs_set_user_money(id,2000)
        
    }
    else if(
time/60 == 60)
    {
        
cs_set_user_money(id,6000)
        
    }
    else if(
time/60 == 120)
    {
        
cs_set_user_money(id,4000)
        
    }
    else if(
time/60 == 180)
    {
        
cs_set_user_money(id,3000)
        
    }
    else 
    { 
        
cs_set_user_money(id,2000
    
    }
    
     

it's not working properly after playing 5 min it's giving me 4000 money

Last edited by Awesome_man; 05-04-2016 at 10:34.
Awesome_man is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 05-08-2016 , 01:54   Re: Whats wrong with this code ?
Reply With Quote #2

test:

PHP Code:
public client_putinserver(id)
{
    if(!
is_user_connected(id))
    {
        return 
PLUGIN_HANDLED
    
}
    
    if(
get_user_time(id1) % 3600 60 240)
    {
        return 
PLUGIN_HANDLED
    

    
    if(
get_user_time(id1) % 3600 60 == 30)
    {
        
cs_set_user_money(id,2000)
        
    }
    
//..

mlibre is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-09-2016 , 07:02   Re: Whats wrong with this code ?
Reply With Quote #3

Because you use == , use comparing symbols instead : <, >. Values can't be exact.
siriusmd99 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-10-2016 , 11:53   Re: Whats wrong with this code ?
Reply With Quote #4

Maybe a switch could help by making it easier to read and edit
Code:
public client_putinserver(id) {     if ( ! is_user_connected(id) )         return         switch ( get_user_time(id, 1) / 60 ) {         case   0 ..  29 : cs_set_user_money(id,2000)         case  30 ..  59 : cs_set_user_money(id,2000)         case  60 .. 119 : cs_set_user_money(id,6000)         case 120 .. 179 : cs_set_user_money(id,4000)         case 180 .. 239 : cs_set_user_money(id,3000)         default : return; // if the value of get_user_time()/60 can't be applied to any of the above alternatives this will be called.     }   }
__________________

Last edited by Black Rose; 05-10-2016 at 11:54.
Black Rose is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-10-2016 , 14:41   Re: Whats wrong with this code ?
Reply With Quote #5

actually
case 0 .. 59 : cs_set_user_money(id,2000)


)
siriusmd99 is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-10-2016 , 14:44   Re: Whats wrong with this code ?
Reply With Quote #6

i dont understand, this native gets time played on current session and he uses it at client putinserver.IT wont give values more then 10 seconds ,will IT?
IT saves played time on disconnect ?
siriusmd99 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-10-2016 , 22:28   Re: Whats wrong with this code ?
Reply With Quote #7

"user time" is time connected to the server, not the map. If you view the info on a server, you'll probably see people with times greater than the map timelimit.
__________________

Last edited by fysiks; 05-10-2016 at 22:28.
fysiks is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-11-2016 , 08:04   Re: Whats wrong with this code ?
Reply With Quote #8

Wait, you mean that i can use this native to show played time of the player without making a plugin that stores played time in nvault?
siriusmd99 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-11-2016 , 08:46   Re: Whats wrong with this code ?
Reply With Quote #9

Quote:
Originally Posted by siriusmd99 View Post
Wait, you mean that i can use this native to show played time of the player without making a plugin that stores played time in nvault?
"user time" is reset when you leave the server (or when your computer fails to re-connect to the server during a map change quick enough, in my experience).

So, if you are trying to maintain the total time a player has been on the server, ever, I would not recommend using "user time". A plugin like you describe would be more reliable.
__________________

Last edited by fysiks; 05-11-2016 at 08:48.
fysiks is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-11-2016 , 09:10   Re: Whats wrong with this code ?
Reply With Quote #10

Yes man, i meant this. If player disconnects then user time resets and this guy is using this native on client_putinserver and it wont give more than 10 seconds because he just connected.
Isn't this true?
siriusmd99 is offline
Reply


Thread Tools
Display Modes

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 18:35.


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