ItsMods

Full Version: self in my own gsc ?!? - SOLVED
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How can i Use the variable "self" in my own .gsc file?

secound:
for what are Arguments, what can i do with them, how can i define them and how can i use them?

execute command:
PHP Code:
self thread maps\mp\gametypes\myfile::myfunktionARGUMENTS ); 
myfile.gsc:
PHP Code:
myfunktionARGUMENTS )
{


Hope, you can help me... Wink
dont use php tags, use [ code] instead

yeah, you can use self but you need to add #include from file like _rank. (if this is what you meant, explain what do you mean by that )

to use variables, do it like that
Code:
giveweapon(weapon)
{
self giveweapon(weapon);
}
and call it like this
Code:
self thread giveweapon(onemanarmy_mp);

thats all, OMA
If you use

Code:
self thread blabla::function()
then "self" will be "self" in your function aswell (I hope you understand)

for example in some files you will find this:
Code:
onPlayerConnected()
{
    while( true )
    {
        level waittill( "connecting", player );
        player thread onPlayerSpawned();
    }
}

onPlayerSpawned()
{
    self endon( "disconnect" );
    for( ;; )
    {
        self waittill( "spawned_player" );
    }
}

the "player" in onPlayerConnected is obviously a player and "onPlayerSpawned" is called from the player so the variable "self" in onPlayerSpawned is that player. Now if I call a function after the player spawned:
Code:
self waittill( "spawned_player" );
self doMyFunction();
then in "doMyFunction" the variable "self" will be the same player as the player in "onPlayerSpawned" and "onPlayerConnect"
(11-02-2011, 16:35)OrangePL Wrote: [ -> ]

(11-02-2011, 16:37)iAegle Wrote: [ -> ]

I have understand the first question but i have still 2 questions:
if i use:
Code:
other_player thread mapsmpgametypesmyfile::myfunktion( ARGUMENTS );
to execute the funktion, can i use "self" in the funktion "myfunktion" to give something the player "other_player" ?

secound:
If i will execute a funktion like:
Code:
if( level.variableone == 1 && self.variabletwo > 2 && variable3 != "tdm" )
{self thread mapsmpgametypesmyfile::myfunktion();}
How can i edit the secound line, so that i can use "level.variableone", "self.variabletwo" and "variable3" in "myfunktion"?

Thx for Answers Smile
Inside a function, 'self' refers to the entity that the function was called on.