Raised This Month: $ Target: $400
 0% 

Run Command When Player Join Team?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
anonpiss
Senior Member
Join Date: Jan 2010
Old 01-03-2010 , 04:03   Run Command When Player Join Team?
Reply With Quote #1

There is an eventscript that can do this.
Code:
import es
from gamethread import delayed

def clientFilter(userid, args):
    if args[0].lower() == 'joinclass':
        delayed(3, es.sexec, (userid, 'say !zspawn'))
    return True

def load():
    es.addons.registerClientCommandFilter(clientFilter)

def unload():
    es.addons.unregisterClientCommandFilter(clientFilter)
If I am not wrong, it makes the player say !zspawn when the player joins a team. Is there anyway I can do this in sourcemod?
anonpiss is offline
G@ngst@r
Member
Join Date: Dec 2009
Old 01-03-2010 , 04:50   Re: Run Command When Player Join Team?
Reply With Quote #2

This code has to work.

Code:
public OnPluginStart()
{
	// we have to hook joinclass command
	RegConsoleCmd("joinclass", OnJoinClass, "Joinclass hook"); 		
}

public Action:OnJoinClass(client, args)
{
           FakeClientCommand(client, "say !zspawn");
           Plugin_Continue;										
}
G@ngst@r is offline
anonpiss
Senior Member
Join Date: Jan 2010
Old 01-03-2010 , 05:55   Re: Run Command When Player Join Team?
Reply With Quote #3

It can compile but I got the error saying:

warning 215: expression has no effect

I loaded the plugin, connect to the server and joined a team, it immediately processed the "say !zspawn".

Thanks!
anonpiss is offline
anonpiss
Senior Member
Join Date: Jan 2010
Old 01-04-2010 , 00:54   Re: Run Command When Player Join Team?
Reply With Quote #4

Err there are problems if the say !zspawn is not delayed for a few seconds.

Like on the ES script, it delays for 3 seconds then only run the command.

Can you check if this correct?

Code:
public OnPluginStart()
{
    RegConsoleCmd("joinclass", OnJoinClass, "Joinclass hook");         
}

public Action:OnJoinClass(client, args)
{
    CreateTimer(3.0, RespawnPlayer, client) 
}

public Action:RespawnPlayer(Handle:timer, any:client)
{
    FakeClientCommand(client, "say !zspawn");
    Plugin_Continue;
}

Last edited by anonpiss; 01-04-2010 at 01:02.
anonpiss is offline
Dragonshadow
BANNED
Join Date: Jun 2008
Old 01-04-2010 , 11:01   Re: Run Command When Player Join Team?
Reply With Quote #5

Quote:
Originally Posted by anonpiss View Post
Err there are problems if the say !zspawn is not delayed for a few seconds.

Like on the ES script, it delays for 3 seconds then only run the command.

Can you check if this correct?

Code:
public OnPluginStart()
{
    RegConsoleCmd("joinclass", OnJoinClass, "Joinclass hook");         
}
 
public Action:OnJoinClass(client, args)
{
    CreateTimer(3.0, RespawnPlayer, client) 
}
 
public Action:RespawnPlayer(Handle:timer, any:client)
{
    FakeClientCommand(client, "say !zspawn");
    Plugin_Continue;
}
Yes that should work.
Dragonshadow is offline
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 09:16.


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