Raised This Month: $ Target: $400
 0% 

Adding up


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 10-14-2010 , 07:30   Adding up
Reply With Quote #1

Hi...

I was working on something , like example :

So first we have a number g_Number[33] which is = 500 ...

Then it shows an hud Message : Energy : g_Number[33] which is 500

Then each 5 seconds ... the g_Number[33] is supposed to increase by 10 , which means its supposed to be 511 ... The hud should show 511 ... but it still shows me 500 .. No errors or warnings, everything runs properly..

Guess : My guess is because i have already done this new g_Number[33] = 500 , it only shows 500 , but not sure , Help ..

Script :

PHP Code:
#include <amxmodx> 

new g_Number[33] = 500 

#define PLUGIN "New Plug-In" 
#define VERSION "1.0" 
#define AUTHOR "Sam" 


public plugin_init() 

    
register_plugin(PLUGINVERSIONAUTHOR
     
    
// Tasks 
    
    
set_task(0.1"ShowNumber",_,_,_"b"
    
set_task(5.0"IncreaseNumber",_,_,_"b"


public 
ShowNumber(id

    
set_hudmessage(021300.600.9401.01.0
    
show_hudmessage(id"Number: %i"g_Number[id]) 


public 
IncreaseNumber(id

    if(
is_user_connected(id) ) 
    { 
        
g_Number[id] = g_Number[id] + 10 
    


__________________
  • Project : Level Plugin
o [||||||||||] - 100%
  • Project : OnePieceMod
o [||||||||||] - 20%
SaM.ThE.MaN is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 10-14-2010 , 08:02   Re: Adding up
Reply With Quote #2

PHP Code:
  set_task(5.0"IncreaseNumber",_,_,_"b"
public 
IncreaseNumber(id)  
{  
    if(
is_user_connected(id) )  
    {  
        
g_Number[id] = g_Number[id] + 10  
    
}  

Whose index is this ?
SpeeDeeR is offline
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 10-14-2010 , 08:09   Re: Adding up
Reply With Quote #3

Quote:
Originally Posted by SpeeDeeR View Post
PHP Code:
  set_task(5.0"IncreaseNumber",_,_,_"b"
public 
IncreaseNumber(id)  
{  
    if(
is_user_connected(id) )  
    {  
        
g_Number[id] = g_Number[id] + 10  
    
}  

Whose index is this ?
what do you mean ...
__________________
  • Project : Level Plugin
o [||||||||||] - 100%
  • Project : OnePieceMod
o [||||||||||] - 20%
SaM.ThE.MaN is offline
Ryokin
Senior Member
Join Date: Jan 2010
Old 10-14-2010 , 08:30   Re: Adding up
Reply With Quote #4

Quote:
Originally Posted by SaM.ThE.MaN View Post
what do you mean ...
there's no index in that func, you need to check
PHP Code:
for (new i=0i<get_maxplayersi++)
{
   if ...

__________________
NH4CL + NaOH -> NH3 + H2O + NaCL
Ryokin is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 10-14-2010 , 08:38   Re: Adding up
Reply With Quote #5

Quote:
Originally Posted by SaM.ThE.MaN View Post
what do you mean ...
I mean that the task doesnt execute on specific user, its just executed globally. So you must either set_task in function bound by players index or use the way above.
SpeeDeeR is offline
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 10-14-2010 , 08:53   Re: Adding up
Reply With Quote #6

Quote:
Originally Posted by Ryokin View Post
there's no index in that func, you need to check
PHP Code:
for (new i=0i<get_maxplayersi++)
{
   if ...

Added that and am getting an error :
PHP Code:
 ErrorSyntax error in the expression, or invalid function call on line 104 
__________________
  • Project : Level Plugin
o [||||||||||] - 100%
  • Project : OnePieceMod
o [||||||||||] - 20%
SaM.ThE.MaN is offline
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 10-14-2010 , 09:05   Re: Adding up
Reply With Quote #7

Ugh he missed this ()

Anyways even when i did this :

PHP Code:
public IncreaseNumber(id)
{
    for(new 
i=0i<get_maxplayers(); i++)
    {
        if(
is_user_connected(id) )
        {
            
g_Number[id] = Number 10
        
}
    }

NO diff ... still the same ...
__________________
  • Project : Level Plugin
o [||||||||||] - 100%
  • Project : OnePieceMod
o [||||||||||] - 20%
SaM.ThE.MaN is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 10-14-2010 , 10:19   Re: Adding up
Reply With Quote #8

I must ask you do you have any idea of what you are doing and why should it be done like that ?
This is one way of doing it.
PHP Code:
public IncreaseNumber() 

    for(new 
id=0id<get_maxplayers(); id++) 
    { 
        if(
is_user_connected(id) ) 
            
g_Number[id] += 10
         



Last edited by SpeeDeeR; 10-14-2010 at 10:49.
SpeeDeeR is offline
SaM.ThE.MaN
Senior Member
Join Date: Jan 2010
Old 10-14-2010 , 10:37   Re: Adding up
Reply With Quote #9

Quote:
Originally Posted by SpeeDeeR View Post
I must ask you do you have any idea of what you are doing and why should it be done like that ?
This is one way of doing it.
PHP Code:
public IncreaseNumber() 

    for(new 
id=0id<get_maxplayers(); id++) 
    { 
        if(
is_user_connected(id) ) 
            
g_Number[id] = Number 10 
         


nothing is happening O.o
__________________
  • Project : Level Plugin
o [||||||||||] - 100%
  • Project : OnePieceMod
o [||||||||||] - 20%
SaM.ThE.MaN is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 10-14-2010 , 10:49   Re: Adding up
Reply With Quote #10

try now
SpeeDeeR is offline
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 10:19.


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