AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   cant get +attack and +attack2 (https://forums.alliedmods.net/showthread.php?t=2301)

Greenberet 06-01-2004 04:39

cant get +attack and +attack2
 
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 }

PM 06-01-2004 06:01

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

Greenberet 06-01-2004 06:46

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

PM 06-01-2004 07:10

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.

Greenberet 06-01-2004 07:15

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

RPRaiden 06-01-2004 21:04

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] ?

XoD 06-04-2004 10:02

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

DopeFish 06-04-2004 14:09

ouch hooking serverframe and checking each player every frame is really going to hurt your cpu ;)

PM 06-04-2004 15:56

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 :D (www.compuphase.com somewhere)

Girthesniper 06-04-2004 17:59

Quote:

std
HEHEH STD!!!! :lol: :lol: :lol:


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

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