AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   new SOMETHING[##] (https://forums.alliedmods.net/showthread.php?t=95463)

HLM 06-23-2009 21:25

new SOMETHING[##]
 
PHP Code:

new szarg1[33], szalpha[8], szarg3[8], bool:mode
    read_argv
(1,szarg1,32)
    
read_argv(2,szalpha,7)
    
read_argv(3,szarg3,7)
    new 
ialpha str_to_num(szalpha)
    if(
equal(szarg3,"on"))
        
mode true
        
        
new pid cmd_target(id,szarg1,2)
        if(
pid 0) {
            
hasinvis[pid] = mode
            
if(mode) {
                        
client_print(pid,print_chat,"-[EVIL]- %s is now cloaked ",name)
                        
set_user_rendering(pid,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,ialpha)
            }
            else {
                       
client_print(pid,print_chat,"-[EVIL]- %s is no longer  ",name)
                       
set_user_rendering(pid,kRenderFxNone,0,0,0,kRenderNormal,ialpha)
            }
        }
    } 

I dont fully understand new (brand new to scripting)

new (creates something) arg (it is called upon in the command?)[] (length?) is this right?

Exolent[jNr] 06-23-2009 21:33

Re: new SOMETHING[##]
 
"new" initializes a new variable.
The name you choose is your choice and has nothing to do with the variable except for when you use it.
The name simply lets you access it and it should describe what the variable is for so it isn't confusing.
You can create cells and arrays of cells.

Code:
new variable; // created a variable called "variable" new variable2[10]; // created an array called "variable2" with 10 slots // the slots can be accessed by using 0 to (slots - 1). // Example: this variable's slots will be accessed with 0 to 9. variable[10] = 1; // this will cause an "index out of bounds" error because this is the 11th slot which does not exist.

To learn Pawn, here are some good tutorials:

http://forums.alliedmods.net/showthread.php?t=94381
http://forums.alliedmods.net/showthread.php?t=91207

EDIT: Hi, fysiks. You beat me before I edited ><

fysiks 06-23-2009 21:34

Re: new SOMETHING[##]
 
Programming for Starters:
http://forums.alliedmods.net/showthread.php?t=91207


All times are GMT -4. The time now is 15:38.

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