AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   action thru register_concmd to dead players (https://forums.alliedmods.net/showthread.php?t=55052)

Voi 05-12-2007 10:48

action thru register_concmd to dead players
 
how to make actions thru register_concmd performing on dead players ?

slmclarengt 05-12-2007 14:01

Re: action thru register_concmd to dead players
 
Quote:

Originally Posted by Voi (Post 475866)
how to make actions thru register_concmd performing on dead players ?

Simple example:
PHP Code:

public plugin_init()
{
register_concmd("amx_function""cmdMyFunc"ADMIN_ADMIN"- To perform action on dead players")
}
public 
cmdMyFunc(id)
{
for (new 
0get_playersnum();i++) // check all players in server
{
   if (!
is_user_alive(i)) // check if they are dead
   
{
       
client_cmd(i"say I am dead - it sucks"// perform the action - in this case say "I am dead - it sucks"
   
}


Slmclarengt

_Master_ 05-12-2007 15:22

Re: action thru register_concmd to dead players
 
PHP Code:

public cmdMyFunc(id){
    new 
players[32], num
    
    get_players
(playersnum"b")
    for(new 
0numi++){
        
//
        // ACTION HERE FOR DEAD PLAYERS (playerid = players[i])
        //
    
}



teame06 05-12-2007 15:22

Re: action thru register_concmd to dead players
 
Quote:

Originally Posted by slmclarengt (Post 475907)
Simple example:
PHP Code:

public plugin_init()
{
register_concmd("amx_function""cmdMyFunc"ADMIN_ADMIN"- To perform action on dead players")
}
public 
cmdMyFunc(id)
{
for (new 
0get_playersnum();i++) // check all players in server
{
   if (!
is_user_alive(i)) // check if they are dead
   
{
       
client_cmd(i"say I am dead - it sucks"// perform the action - in this case say "I am dead - it sucks"
   
}


Slmclarengt

get_playersnum() << Only return the number of players in the server unless you specify the first parameter it then it will include the number of player in and connecting to the server.

Let say get_playersnum() return 5 but let say player 1 is in slot 1, player 2 is in slot 3, player 3 is in slot 5, and player 4 is in slot 9, and player 5 is in slot 10.

That for loop will only go out to 4. Skippign player 3, 4, 5. Also player id start from 1 not 0. If you use use on some depending on the native it will throw an error.

So use get_players() or get_maxplayers().

Voi 05-13-2007 06:40

Re: action thru register_concmd to dead players
 
uh, actually i wanted this command on single persons wherever they dead or not

thx for help

slmclarengt 05-13-2007 13:38

Re: action thru register_concmd to dead players
 
Quote:

Originally Posted by teame06 (Post 475936)
get_playersnum() << Only return the number of players in the server unless you specify the first parameter it then it will include the number of player in and connecting to the server.

Let say get_playersnum() return 5 but let say player 1 is in slot 1, player 2 is in slot 3, player 3 is in slot 5, and player 4 is in slot 9, and player 5 is in slot 10.

That for loop will only go out to 4. Skippign player 3, 4, 5. Also player id start from 1 not 0. If you use use on some depending on the native it will throw an error.

So use get_players() or get_maxplayers().

I'm well aware as I have used those other functions before; when I wrote this I was in a rush and just grabbed the function off the top of my head without any real pre-thought but I remembered I should be using get_players() but didn't want/have the time to fix it.

@ Voi - what do you mean? Do you want the player to type something like /amidead and the plugin to check if their dead and if they are, tell them? Or do you want it to automatically tell everyone when they die that they died (not like that's completely obvious or anything :-)).

Slmclarengt

Voi 05-20-2007 11:59

Re: action thru register_concmd to dead players
 
no, something like admin writes "amx_something playername" and a function is executed on that player wherever he is dead or not, for example client_print and client_cmd and perhaps emit_sound

Minimum 05-20-2007 17:22

Re: action thru register_concmd to dead players
 
Is this what you are looking for?

Code:
public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_concmd("amx_func","MyFunc",ADMIN_ADMIN,"My Function's Description") } public MyFunc(id) {     new playerid, playername[64]     read_argv(1,playername,63)     // Flag Ids - cmd_target(adminid,playername,flagid)     // 1 - obey immunity     // 2 - allow yourself     // 4 - must be alive     // 8 - can't be bot     playerid = cmd_target(id,playername,2)     client_print(playerid,print_chat,"Oh no!  Someone has executed amx_func on you!") }

Voi 05-20-2007 17:35

Re: action thru register_concmd to dead players
 
yes, thank you very much :up:


All times are GMT -4. The time now is 06:42.

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