Jump to content

- Advertisement -
Photo

[CS16-Scripting] Automatons


  • Please log in to reply
No replies to this topic

#1
Andrei;

Andrei;

    Administrator

  • Administrator
  • 3201 posts
  • 398 topics
  • Joined 16-December 12
  • Country: Country Flag

Cel mai bine va pot explica printr-un cod:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

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


public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	state disabled
	register_srvcmd( "/test", "test" )
	register_srvcmd( "disable", "Disable" )
	register_srvcmd( "enable", "Enable" )
}

public test ( ) < enabled >
{
	server_print( "test1" )
}

public test ( ) < disabled >
{
	server_print( "test2" )
}

public Enable(  )
{
	state enabled
}

public Disable( )
{
	state disabled
}
  • state poate sa fie orice, de exemplu: state happy
  • dupa cum vedeti, acelasi public apare de 2 ori. Cand va fi chemat, in functie de ce state e setat, va decide pe care sa il execute.
  • daca state este disabled va printa test2, daca state este enabled va printa test1.

Mai sus am inregistrat niste comenzi pentru a schimba state, in mod default state este disabled( dupa cum am pus in plugin_init ).

 

Nu se poate explica prea mult in cuvinte, cel mai bine este sa va mai dau un exemplu:

public test( ) < >
{
    //cod
    state disabled
}

public test( ) < disabled >
{
    return 0
}
  • dupa ce test este chemat prima data, state devine disabled. Cum in publicul test cu state disabled am pus return 0, codul din test se va executa doar o data.

 


  • appLy^NxT likes this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users