AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How do I call a registered event? (https://forums.alliedmods.net/showthread.php?t=302768)

suhdude 11-10-2017 12:40

How do I call a registered event?
 
[SOLVED]

Code:
register_logevent("logevent_function_p", 3, "2=Planted_The_Bomb")

I want the round timer to be removed, and the c4 timer to appear.
I think this event will do that, but I don't know how to call it. (Beginner)

I use a script that auto plants the bomb, but it does not remove the timer.

Thank you!

HamletEagle 11-10-2017 13:43

Re: How do I call a registered event?
 
You do not call events, you hook events. This even is simply called when the bomb is planted, far from what you want to do. To change the timer you need to send a RoundTime message: https://wiki.alliedmods.net/Half-Lif...ents#RoundTime
If you want to hide the timer, then send a BombDrop https://wiki.alliedmods.net/Half-Lif...vents#BombDrop message with Flag = 1.

How to send messages? message_begin + ... + message_end.

suhdude 11-10-2017 14:48

Re: How do I call a registered event?
 
Quote:

Originally Posted by HamletEagle (Post 2559611)
You do not call events, you hook events. This even is simply called when the bomb is planted, far from what you want to do. To change the timer you need to send a RoundTime message: https://wiki.alliedmods.net/Half-Lif...ents#RoundTime
If you want to hide the timer, then send a BombDrop https://wiki.alliedmods.net/Half-Lif...vents#BombDrop message with Flag = 1.

How to send messages? message_begin + ... + message_end.

That was exactly what I was looking for!
Thanks for pointing me in the right direction again.

Its working, but on the radar the bomb is planted in a different place..
Oh well :)

HamletEagle 11-10-2017 14:59

Re: How do I call a registered event?
 
Send the correct bomb origin in BombDrop message to update the radar.

suhdude 11-10-2017 17:01

Re: How do I call a registered event?
 
Quote:

Originally Posted by HamletEagle (Post 2559637)
Send the correct bomb origin in BombDrop message to update the radar.

I have to do this for every map or is there a way to set it to player location?
Whatever, it is not important in this retake scenario :)

HamletEagle 11-10-2017 17:22

Re: How do I call a registered event?
 
get_user_origin

suhdude 11-10-2017 17:30

Re: How do I call a registered event?
 
Quote:

Originally Posted by HamletEagle (Post 2559673)
get_user_origin

Code:
{ get_user_origin(index, c4origin[3], mode = 0); message_begin(MSG_ALL, get_user_msgid("BombDrop"), {0,0,0}, 1) write_byte (c4origin); write_byte (c4origin); write_byte (c4origin); write_byte (1); write_byte (1); write_byte (1); write_byte (1); message_end(); }

This cant be right.. lol

KiLLeR. 11-10-2017 17:40

Re: How do I call a registered event?
 
Quote:

Originally Posted by suhdude (Post 2559676)
Code:
{ get_user_origin(index, c4origin[3], mode = 0); message_begin(MSG_ALL, get_user_msgid("BombDrop"), {0,0,0}, 1) write_byte (c4origin); write_byte (c4origin); write_byte (c4origin); write_byte (1); write_byte (1); write_byte (1); write_byte (1); message_end(); }

This cant be right.. lol

Code:
message_begin(MSG_ALL, get_user_msgid("BombDrop"), {0,0,0}, 1) write_byte(c4origin[0]); write_byte(c4origin[1]); write_byte(c4origin[2]); write_byte(1); message_end();

suhdude 11-10-2017 18:14

Re: How do I call a registered event?
 
Quote:

Originally Posted by KiLLeR. (Post 2559679)
Code:
message_begin(MSG_ALL, get_user_msgid("BombDrop"), {0,0,0}, 1) write_byte(c4origin[0]); write_byte(c4origin[1]); write_byte(c4origin[2]); write_byte(1); message_end();

I get "Error: Undefined symbol "c4origin""

Code:
public delete_clock(id) { get_user_origin(id, c4origin[3], mode = 0); message_begin(MSG_ALL, get_user_msgid("BombDrop"), {0,0,0}, 1) write_byte(c4origin[0]); write_byte(c4origin[1]); write_byte(c4origin[2]); write_byte(1); message_end(); }

HamletEagle 11-10-2017 18:25

Re: How do I call a registered event?
 
You have to define it(new ...)

suhdude 11-10-2017 18:47

Re: How do I call a registered event?
 
Quote:

Originally Posted by HamletEagle (Post 2559687)
You have to define it(new ...)

new c4origin=(player)?
new c4origin[3]?
new c4origin get_user_origin(id, c4origin[3], mode = 0);?

I don't understand, sorry.

wickedd 11-10-2017 19:02

Re: How do I call a registered event?
 
PHP Code:

new c4origin[3


suhdude 11-10-2017 19:10

Re: How do I call a registered event?
 
Quote:

Originally Posted by wickedd (Post 2559693)
PHP Code:

new c4origin[3


Error: Array index out of bounds (variable "c4origin") on line 40
line 40: get_user_origin(id, c4origin[3], mode = 0);

wickedd 11-10-2017 19:16

Re: How do I call a registered event?
 
Post your code

suhdude 11-10-2017 19:23

Re: How do I call a registered event?
 
Quote:

Originally Posted by wickedd (Post 2559696)
Post your code

Code:
#include <amxmodx> #include <fakemeta> #include <fun> #include <cstrike> #define PLUGIN "Spawnplant" #define VERSION "1.0" #define AUTHOR "suhdude/alliedmodders" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_event("HLTV", "new_round", "a", "1=0", "2=0"); } stock is_user_in_plant_zone( id ) {     return (cs_get_user_mapzones(id) & CS_MAPZONE_BOMBTARGET) } public new_round() {     new players[32];     new playercount, i;     get_players(players, playercount);     for (i=0; i<playercount; i++)         set_task(0.5,"plant_bomb",players[i]);         set_task(0.5,"delete_clock");     return PLUGIN_CONTINUE; } public plant_bomb(id) {     if ( is_user_in_plant_zone( id ) )     {         client_cmd (id,"say /plant"); //activates another plugin that plants the bomb.         client_print( 0, print_center, "#Cstrike_TitlesTXT_Bomb_Planted" );     } }   public delete_clock(id) { new c4origin[3]   get_user_origin(id, c4origin[3], mode = 0); message_begin(MSG_ALL, get_user_msgid("BombDrop"), {0,0,0}, 1) write_byte(c4origin[0]); write_byte(c4origin[1]); write_byte(c4origin[2]); write_byte(1); message_end(); }

Thanks for helping out!

wickedd 11-10-2017 19:33

Re: How do I call a registered event?
 
PHP Code:

get_user_origin(idc4origin[3], mode 0); 

:arrow:
PHP Code:

get_user_originidc4origin ); 


KiLLeR. 11-10-2017 19:40

Re: How do I call a registered event?
 
new Float:name[3];

Pawn is not that clever to create variable instead of you. :D

suhdude 11-10-2017 19:54

Re: How do I call a registered event?
 
Quote:

Originally Posted by wickedd (Post 2559699)
PHP Code:

get_user_origin(idc4origin[3], mode 0); 

:arrow:
PHP Code:

get_user_originidc4origin ); 


Hmm, now the dot is nowhere on the radar and the clock is not removed.
Looks like this now:

Code:
public delete_clock(id) { new Float:c4origin[3]; get_user_origin( id, c4origin ); message_begin(MSG_ALL, get_user_msgid("BombDrop"), {0,0,0}, 1) write_byte(c4origin[0]); write_byte(c4origin[1]); write_byte(c4origin[2]); write_byte(1); message_end()}

Thanks.

HamletEagle 11-11-2017 03:49

Re: How do I call a registered event?
 
It should not be Float:. get_user_origin works woth integers.

Also in message_begik why do you use the 1 at the end?

suhdude 11-11-2017 09:14

Re: How do I call a registered event?
 
Quote:

Originally Posted by HamletEagle (Post 2559743)
It should not be Float:. get_user_origin works woth integers.

Also in message_begik why do you use the 1 at the end?

Maybe I missunderstood this:

Quote:

The first three arguments are the origin of the dropped bomb. The last argument is set to 0 if the bomb was dropped due to voluntary dropping or death/disconnect. It is set to 1 if the bomb was planted, which will trigger the round timer to hide. It also will show the dropped bomb on the Terrorist team's radar in the location specified by the first three arguments.
Timer is still there, I removed the float: and the "write_byte(1);"

HamletEagle 11-11-2017 09:39

Re: How do I call a registered event?
 
write_byte was correct. I'm talking about the 1 from message_begin.

Are you sure you are actually compiling and changing the plugin? Since you removed the last write_byte the server should crash.

suhdude 11-11-2017 09:43

Re: How do I call a registered event?
 
Quote:

Originally Posted by HamletEagle (Post 2559795)
write_byte was correct. I'm talking about the 1 from message_begin.

Are you sure you are actually compiling and changing the plugin? Since you removed the last write_byte the server should crash.

Yes I compile and restart the server completely every time.
Right now the clock is still there and nothing on radar:

Code:
public delete_clock(id) { new c4origin[3]; get_user_origin( id, c4origin ); message_begin(MSG_ALL, get_user_msgid("BombDrop"), {0,0,0}) write_byte (c4origin[0]); write_byte (c4origin[1]); write_byte (c4origin[2]); write_byte (1); message_end(); }

suhdude 11-11-2017 09:47

Re: How do I call a registered event?
 
Quote:

Originally Posted by HamletEagle (Post 2559795)
write_byte was correct. I'm talking about the 1 from message_begin.

Are you sure you are actually compiling and changing the plugin? Since you removed the last write_byte the server should crash.

Actually this is not important, I have a way bigger problem of the players getting stuck in the bomb on forceplant. :D
If I only could set mp_roundtime below 1 minute, it would at least match the c4 timer.

Thanks HamletEagle for wanting to help, and sorry if I'm a slow learner.

HamletEagle 11-11-2017 10:03

Re: How do I call a registered event?
 
What is delete_clock? How is it called?

suhdude 11-11-2017 10:18

Re: How do I call a registered event?
 
Quote:

Originally Posted by HamletEagle (Post 2559801)
What is delete_clock? How is it called?

Code:
#include <amxmodx> #include <fakemeta> #include <cstrike> #define PLUGIN "Spawnplant" #define VERSION "1.0" #define AUTHOR "NyburgarN" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_event("HLTV", "new_round", "a", "1=0", "2=0"); } stock is_user_in_plant_zone( id ) {     return (cs_get_user_mapzones(id) & CS_MAPZONE_BOMBTARGET) } public new_round() {     new players[32];     new playercount, i;     get_players(players, playercount);     for (i=0; i<playercount; i++)         set_task(0.5,"plant_bomb",players[i]);         set_task(0.5,"delete_clock"); //<-------------------------------------------------------------------------------- Called here     return PLUGIN_CONTINUE; } public plant_bomb(id) {     if ( is_user_in_plant_zone( id ) )     {         client_cmd (id,"say /plant"); //This activates another plugin         client_print( 0, print_center, "#Cstrike_TitlesTXT_Bomb_Planted" );     } }   public delete_clock(id) { new c4origin[3]; get_user_origin( id, c4origin ); message_begin(MSG_ALL, get_user_msgid("BombDrop")) write_byte (c4origin[0]); write_byte (c4origin[1]); write_byte (c4origin[2]); write_byte (1); message_end(); }

HamletEagle 11-11-2017 12:32

Re: How do I call a registered event?
 
delete_clock is not passing any player index.
set_task(0.5,"delete_clock"); -> set_task(0.5,"delete_clock", players[i]);

suhdude 11-11-2017 13:05

Re: How do I call a registered event?
 
Edit: I got it working with:

Code:
new g_c4timer new mp_c4timer public plugin_init() {     register_event("HLTV", "new_round", "a", "1=0", "2=0");     mp_c4timer  = get_cvar_pointer("mp_c4timer") } public event_hltv()     g_c4timer = get_pcvar_num(mp_c4timer) public change_clock(id) {     message_begin(MSG_ALL, get_user_msgid("RoundTime"))     write_short (g_c4timer);     message_end(); }

Thanks for helping me out HamletEagle!


All times are GMT -4. The time now is 07:43.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.