//This makes it so you can use the core AMX Mod X functions //It "includes" the native definitions from includes\amxmodx.inc #include<amxmodx>
//Declare three string variables new PLUGIN[]="AMXX Demo" new AUTHOR[]="BAILOPAN" new VERSION[]="1.00"
//This is a public function. //It is necessary to initialize your script under AMX Mod X. //It takes no parameters, and is called right after map load. publicplugin_init() { //This is a function that takes three strings. //It registers your function in AMX Mod X, and assigns some basic information. register_plugin(PLUGIN, VERSION, AUTHOR) }
//Get the command arguments from the console read_argv(1, Arg1, 23) read_argv(2, Arg2, 3)
//Convert the health from a string to a number new Health = str_to_num(Arg2)
//Is the first character the @ symbol? if (Arg1[0] == '@') { new Team = 0 //Check which team was specified. //Note that we start from [1], this is okay // it just means the @ isn't included if (equali(Arg1[1], "CT")) { Team = 2 } elseif (equali(Arg1[1], "T")) { Team = 1 } new players[32], num //This function will fill the players[32] variable // with valid player ids. num will contain the number // of players that are valid. get_players(players, num) new i for (i=0; i<num; i++) { if (!Team) { //Set this player's health set_user_health(players[i], Health) } else { if (get_user_team(players[i]) == Team) { set_user_health(players[i], Health) } } } } else { //finds a player id that matches the partial name given //the 1 means that it will not target the player if he // has immunity access new player = cmd_target(id, Arg1, 1) if (!player) { //this will print a message to the user who tried the command //The format for this command is called "format()" style, // where the first string formats the message according // to any number of following parameters. // %s means a string // %d or %i means an integer // %f means a float // so "Hello %s, I am %d years old" will // require a string and integer to follow console_print(id, "Sorry, player %s could not be found or targetted!", Arg1) return PLUGIN_HANDLED } else { set_user_health(player, Health) } }
//Get the command arguments from the console read_argv(1, Arg1, 23) read_argv(2, Arg2, 3)
//Convert the health from a string to a number new Health = str_to_num(Arg2)
//Is the first character the @ symbol? if (Arg1[0] == '@') { new Team = 0 if (equali(Arg1[1], "CT")) { Team = 2 } elseif (equali(Arg1[1], "T")) { Team = 1 } new players[32], num get_players(players, num) new i for (i=0; i<num; i++) { if (!Team) { set_user_health(players[i], Health) } else { if (get_user_team(players[i]) == Team) { set_user_health(players[i], Health) } } } } else { new player = cmd_target(id, Arg1, 1) if (!player) { console_print(id, "Sorry, player %s could not be found or targetted!", Arg1) return PLUGIN_HANDLED } else { set_user_health(player, Health) } }
publicplugin_init() { register_plugin("CVAR Test", "1.0", "BAILOPAN") //set default value to 500 register_cvar("amx_startmoney", "500") }
//this occurs when a client is put in game publicclient_putinserver(id) { if (get_cvar_num("amx_startmoney") > 0) { cs_set_user_money(id, get_cvar_num("amx_startmoney")) } else { cs_set_user_money(id, get_cvar_num("mp_startmoney")) } }