Raised This Month: $ Target: $400
 0% 

difference between new and static?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 04-25-2012 , 07:22   Re: difference between new and static?
Reply With Quote #7

PHP Code:
#include <amxmodx>
#include <amxmisc>


public plugin_init()
{
    
register_plugin"test plugin""1.0""Dare-Devil" )
    
register_clcmd("say t""call_Testing")
}

public 
call_Testing(id)
{
    
test(12)
    
test(21)
    
test(102)
    
test(201)
}

test(testparam)
{
    static 
hj
    hj
++
    
client_print(0print_chat"hj: %d"hj)

Quote:
// result:
hj: 1
hj: 2
hj: 3
hj: 4
what I hoped
Quote:
// result:
hj: 1
hj: 1
hj: 1
hj: 1
so it seems that if function param is different the system still use same variable.
Anyway in the entity thinking i must do

PHP Code:
entitythink(ent)
{
   static 
entvariable[512]
   
entvariable[Ent] += something


this way my data will not get corrupted.
I get all information what i want, thanks!

Last edited by .Dare Devil.; 04-25-2012 at 07:23.
.Dare Devil. is offline
 



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 07:47.


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