Raised This Month: $ Target: $400
 0% 

cant get +attack and +attack2


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 06-01-2004 , 04:39   cant get +attack and +attack2
Reply With Quote #1

hi,
why cant i get +attack and +attack2???

i mean like this:
Code:
public plugin_init() {     register_plugin("+attack test","1.0","Greene")     register_clcmd("+attack","attack1")     register_clcmd("+attack2","attack2")     return PLUGIN_CONTINUE }
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 06-01-2004 , 06:01  
Reply With Quote #2

You can't because these are executed client side. The client sends a code rather than the whole command to the server (because these buttons are pressed often).

To execute a function when a player presses attack, i think this should work:

Code:
new g_OldButtons[32]; public server_frame() {    new newButtons[32];    new i, pressedButtons;    for (i=0; i<32; ++i)    {       newButtons[i] = get_user_button(i);       pressedButtons = (newButtons[i] ^ g_OldButtons[i]) & newButtons[i];       if (pressedButtons & IN_ATTACK)          some_func(i);       g_OldButtons[i] = newButtons[i];    } }

That could work (not tested)

get_user_button and IN_ATTACK are defined in engine_stocks.inc and engine_const.inc, so you only have to #include <engine>.

PS: I don't use get_user_oldbutton because it acted weird for me
__________________
hello, i am pm
PM is offline
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 06-01-2004 , 06:46  
Reply With Quote #3

thx, now i have a other prob:
i would like to render someone, but ir should be visible to only one player
but when i use the function i become an error(look at the attachement)
Code:
public render(id) {     new client[32],count     get_players( client, count, "")     for(new core=0; core < 33; core++)     {         new origin[33][3]         new idt=client[core]         get_user_origin(idt,origin[idt],0)         message_begin( MSG_ONE, SVC_TEMPENTITY,origin[idt],id)         if(get_user_team(id)==get_user_team(idt))             set_rendering(idt, kRenderFxNone,255,255,255,kRenderNormal,0)         else             set_rendering(idt, kRenderFxNone,255,0,0,kRenderNormal,0)         message_end()     }     message_end()     return PLUGIN_HANDLED }

P.S:i used set_rendering , because set_user_rendering mades the same error

LG
Green
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 06-01-2004 , 07:10  
Reply With Quote #4

What do you want to render?
message_begin( MSG_ONE, SVC_TEMPENTITY,origin[idt],id)
=> this starts a tempentity message. Then you have to use the write_* functions to specify the type and the parameters. You don't specify a type so you get the error

All types and parameters are listed in the Multiplayer Source/common/const.h file in the HLSdk.
__________________
hello, i am pm
PM is offline
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 06-01-2004 , 07:15  
Reply With Quote #5

i would like to render the players in the same team with white, and the players on the enemy team in red, but it should be only visible to one player
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
RPRaiden
Member
Join Date: Apr 2004
Location: UK
Old 06-01-2004 , 21:04  
Reply With Quote #6

Quote:
Originally Posted by PM
You can't because these are executed client side. The client sends a code rather than the whole command to the server (because these buttons are pressed often).

To execute a function when a player presses attack, i think this should work:

Code:
new g_OldButtons[32]; public server_frame() {    new newButtons[32];    new i, pressedButtons;    for (i=0; i<32; ++i)    {       newButtons[i] = get_user_button(i);       pressedButtons = (newButtons[i] ^ g_OldButtons[i]) & newButtons[i];       if (pressedButtons & IN_ATTACK)          some_func(i);       g_OldButtons[i] = newButtons[i];    } }

That could work (not tested)

get_user_button and IN_ATTACK are defined in engine_stocks.inc and engine_const.inc, so you only have to #include <engine>.

PS: I don't use get_user_oldbutton because it acted weird for me
For a newb like me, why was you using [i] ?
__________________
RPRaiden is offline
Send a message via ICQ to RPRaiden Send a message via AIM to RPRaiden Send a message via MSN to RPRaiden Send a message via Yahoo to RPRaiden
XoD
Junior Member
Join Date: Apr 2004
Old 06-04-2004 , 10:02  
Reply With Quote #7

I think (noob, too) that he used the for (i=0; i<32; ++i) and [i] to let this check all possible users on the server
XoD is offline
DopeFish
Senior Member
Join Date: Feb 2004
Old 06-04-2004 , 14:09  
Reply With Quote #8

ouch hooking serverframe and checking each player every frame is really going to hurt your cpu ;)
DopeFish is offline
Send a message via ICQ to DopeFish
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 06-04-2004 , 15:56  
Reply With Quote #9

what else should i do dopefish? It could be done in a module, but it isnt in any std module, so i need to hook serverframe..
[i] : for arrays, look into small doc (www.compuphase.com somewhere)
__________________
hello, i am pm
PM is offline
Girthesniper
Senior Member
Join Date: Mar 2004
Location: Maryland
Old 06-04-2004 , 17:59  
Reply With Quote #10

Quote:
std
HEHEH STD!!!!
__________________
BANNED
Girthesniper is offline
Send a message via AIM to Girthesniper Send a message via MSN to Girthesniper
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:44.


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