Help with say /stats
MasamuneDate
12.05.2020
So, im a little bit confused on how to store the data.
If i write the code on Java or C, what will i do is that i will put the one function, on outside of the ham spawn, but i cant do that on PAWN.
Any suggestion ?
What i want to do is, when you level up, you automaticly say /stats.
Like /class, when you connect to server, you got no class, so you will automaticly say /class after spawn.
Załączone pliki
Rivit
12.05.2020
You should put
client_cmd(id, "say /stats")
in cod mod core because default implementation of cod doesnt provide method to catch level up.
Same with /class
For /stats you can do something like this:
else if(zdobyl_poziom) { punkty_gracza[id] = (poziom_gracza[id]-1)*2-inteligencja_gracza[id]-zdrowie_gracza[id]-wytrzymalosc_gracza[id]-kondycja_gracza[id]; set_hudmessage(212, 255, 85, 0.31, 0.32, 0, 6.0, 5.0); ShowSyncHudMsg(id, SyncHudObj2,"Awansowales do %i poziomu!", poziom_gracza[id]); client_cmd(id, "spk QTM_CodMod/levelup"); //put your code here or call 'PrzydzielPunkty(id)' }
For /class
if(!klasa_gracza[id]) { WybierzKlase(id); return PLUGIN_CONTINUE; }
It is actually in the core (Ham_Spawn handler).
MasamuneDate
13.05.2020
You should put
client_cmd (id, "say / stats")in cod mod core because default implementation of cod doesnt provide method to catch level up.
Same with / class
For / stats you can do something like this:
else if (reached_level) { player_points [id] = (player_level [id] -1) * 2-player_intelligence [id] - player_health [id]-player_health [id] -condition_condition [id]; set_hudmessage (212, 255, 85, 0.31, 0.32, 0, 6.0, 5.0); ShowSyncHudMsg (id, SyncHudObj2, "You have advanced to% i level!", Player_level [id]); client_cmd (id, "spk QTM_CodMod / levelup"); // put your code here or call 'Assign Points (id)' }For / class
if (! player_class [id]) { Select Class (d); return PLUGIN_CONTINUE; }It is actually in the core (Ham_Spawn handler).
well
What i mean is
Case 1, When player enter the server, its obviously he will have no class (lack). So if i cod_get_user_class, the function will return 0.
So in ham spawn, i just need to write> if (cod_get_user_class = 0), just client_cmd say / class. Which is already done
But for Case 2
When player Lv up, what i want in the next round is that they automatically say / stats.
But the problem is im pretty confused how to do it. If this were C Language, i can make the function of new data = cod_get_user_level as a global variable, so its only run once, when the plugin started. Then on another function i would make, i will make a new data2 = cod_get_user_level on everyround.
So when player lv up, it will be like this
if (data2> data), then say / stats, and then data = data2.
But on PAWN i cant do that, so any advice? I just want to make a simple say program when a player lv up.
EDITTED
PS. /class, and /stats already available on my cod mod core. I forgot to say
Użytkownik MasamuneDate edytował ten post 13.05.2020 06:48
Rivit
13.05.2020
What i mean is
Case 1, When player enter the server, its obviously he will have no class (lack). So if i cod_get_user_class, the function will return 0.
So in ham spawn, i just need to write> if (cod_get_user_class = 0), just client_cmd say / class. Which is already done
I know, but this is default cod mod behavior. It is already implemented in cod mod core.
I really dont know what you want to do because this both mechanics are present in cod mod
You can do something like this. Just get level when player changes class and update old level every spawn
#include <amxmodx> #include <hamsandwich> #include <codmod> #define PLUGIN "Say /class & /stats" #define VERSION "0.1" #define AUTHOR "MasamuneDate / TYR" new oldLevel[33]; public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) RegisterHam(Ham_Spawn, "player", "Fw_Spawn", 1) } public Fw_Spawn(id) { if(!is_user_alive(id)){ return HAM_IGNORED; } new currentLevel = cod_get_user_level(id); new classid = cod_get_user_class(id); if(classid == 0) { client_cmd(id, "say /class") } else if(oldLevel[id] < currentLevel) { client_cmd(id, "say /stats") } oldLevel[id] = currentLevel; //update current level return HAM_IGNORED; } public client_connect(id){ oldLevel[id] = -1; //reset data } public cod_class_changed(id, klasa){ set_task(1.0, "wait_for_data", id); //we have to wait because cod_class_changed is called before load class data } public wait_for_data(id){ oldLevel[id] = cod_get_user_level(id); //remember current level }
MasamuneDate
14.05.2020
What i mean is
Case 1, When player enter the server, its obviously he will have no class (lack). So if i cod_get_user_class, the function will return 0.
So in ham spawn, i just need to write> if (cod_get_user_class = 0), just client_cmd say / class. Which is already done
I know, but this is default cod mod behavior. It is already implemented in cod mod core.
I really dont know what you want to do because this both mechanics are present in cod mod
You can do something like this. Just get level when player changes class and update old level every spawn
#include <amxmodx> #include <hamsandwich> #include <codmod> #define PLUGIN "Say / class & / stats" #define VERSION "0.1" #define AUTHOR "MasamuneDate / TYR" new oldLevel [33]; public plugin_init () { register_plugin (PLUGIN, VERSION, AUTHOR) RegisterHam (Ham_Spawn, "player", "Fw_Spawn", 1) } public Fw_Spawn (id) { if (! is_user_alive (id)) { return HAM_IGNORED; } new currentLevel = cod_get_user_level (id); new classid = cod_get_user_class (id); if (classid == 0) { client_cmd (id, "say / class") } else if (oldLevel [id] <currentLevel) { client_cmd (id, "say / stats") } oldLevel [id] = currentLevel; // update current level return HAM_IGNORED; } public client_connect (id) { oldLevel [id] = -1; // reset data } public cod_class_changed (id, class) { set_task (1.0, "wait_for_data", id); // we have to wait because cod_class_changed is called before load class data } public wait_for_data (id) { oldLevel [id] = cod_get_user_level (id); // remember current level }
okay thanks, and it works, thank you very much !
Użytkownik MasamuneDate edytował ten post 14.05.2020 04:59