Thread: Need help!!
View Single Post
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-02-2015 , 07:07   Re: Need help!!
Reply With Quote #9

if(!var) is the same as if(var==0) and check if the given variable is 0(false). When dealing with teams it is unassigned team(not t, ct or spec). If you use cstrike module the const is CS_TEAM_UNASSIGNED which is 0. This is why it checks like that.

PHP Code:
enum CsTeams {
    
CS_TEAM_UNASSIGNED 0,
    
CS_TEAM_T 1,
    
CS_TEAM_CT 2,
    
CS_TEAM_SPECTATOR 3
}; 
Also, when you initialize a variable without giving it a value it will be everytime 0, so you don't have to explicit:
PHP Code:
 new test new bool:test false new FloatfTest 0.0 
If you know C, then go and read here about pawn language: http://www.compuphase.com/pawn/Pawn_Language_Guide.pdf

You will notice some differences between it and C:
-no pointers
-no types. Because everything is a integer cell we use tags for floats and booleans. A string is an array of cells.
-etc

PHP Code:
new ThisIsMyString[] = "Test"//you don't need to write the size between[], compiler is able to find it
new SomeArray[5]
SomeArray[0] = 'a'
SomeArray[1] = 'b'
SomeArray[2] = 'c'
SomeArray[3] = 'd'
SomeArray[4] = 'e' 
When you print SomeArray it will give you abcde. Note that this kind of assigment can't be done globally and need to be in a function, otherwise the copiler will throw an error.

The last cell from an array must be the null item, defined as EOS in amxx.(end of string)
If you try to store something in SomeArray[5] you can't.
So the usable cells of an array are from 0 to sizeof -1(defined as charsmax(string))

To remove the tag from a variable use _: in front of it's name. It's also used for enumeration(enum) when you want to untag it.

To check if the two variable tags match you can use tagof operator(read in pawn manual about it).
__________________

Last edited by HamletEagle; 01-02-2015 at 07:24.
HamletEagle is offline