Raised This Month: $51 Target: $400
 12% 

run fakecommand when client joins a team


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PresidentEvil
AlliedModders Donor
Join Date: Jun 2012
Old 03-01-2016 , 21:07   run fakecommand when client joins a team
Reply With Quote #1

how do I change this code so it execs the fake command when player joins a team instead of when the join the server

Code:
#include <sourcemod>

public Plugin myinfo = 
{
name = "",
author = "",
description = "",
version = "",
url = ""
};

public void  OnClientPutInServer(int client)
{
FakeClientCommand(client, "say /zspawn");
}
pls and thank you
__________________
PresidentEvil is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 03-01-2016 , 21:13   Re: run fakecommand when client joins a team
Reply With Quote #2

If you want a autozspawn you can use this:
Code:
#include <sourcemod>

public OnPluginStart()
{	
	HookEvent("player_team", Event_OnPlayerTeam, EventHookMode_Pre);	
}

public Action:Event_OnPlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    if(!client || !IsClientInGame(client))
        return Plugin_Continue;

    if(!IsPlayerAlive(client))
        CreateTimer(0.1, Timer_ZSpawn, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
        
    return Plugin_Continue;
}

public Action:Timer_ZSpawn(Handle:timer, any:userid)
{
    new client = GetClientOfUserId(userid);
    if(!client)
        return Plugin_Continue;

    new iTeam = GetClientTeam(client);
    if(iTeam <= 1)
        return Plugin_Continue;

    if(IsPlayerAlive(client))
        return Plugin_Continue;

    ClientCommand(client, "zspawn");

    return Plugin_Continue;
}
Its a simple code for autozspawn and works well with my zombiereloaded edition.
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.


Last edited by Franc1sco; 03-01-2016 at 21:16.
Franc1sco is offline
Send a message via MSN to Franc1sco
PresidentEvil
AlliedModders Donor
Join Date: Jun 2012
Old 03-01-2016 , 22:02   Re: run fakecommand when client joins a team
Reply With Quote #3

thank you Frani
__________________
PresidentEvil is offline
Sipro
Junior Member
Join Date: Dec 2016
Old 03-31-2018 , 10:10   Re: run fakecommand when client joins a team
Reply With Quote #4

Quote:
Originally Posted by Franc1sco View Post
If you want a autozspawn you can use this:
Code:
#include <sourcemod>

public OnPluginStart()
{	
	HookEvent("player_team", Event_OnPlayerTeam, EventHookMode_Pre);	
}

public Action:Event_OnPlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    if(!client || !IsClientInGame(client))
        return Plugin_Continue;

    if(!IsPlayerAlive(client))
        CreateTimer(0.1, Timer_ZSpawn, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
        
    return Plugin_Continue;
}

public Action:Timer_ZSpawn(Handle:timer, any:userid)
{
    new client = GetClientOfUserId(userid);
    if(!client)
        return Plugin_Continue;

    new iTeam = GetClientTeam(client);
    if(iTeam <= 1)
        return Plugin_Continue;

    if(IsPlayerAlive(client))
        return Plugin_Continue;

    ClientCommand(client, "zspawn");

    return Plugin_Continue;
}
Its a simple code for autozspawn and works well with my zombiereloaded edition.
That is working for CS:S ?
Sipro is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 03-31-2018 , 10:29   Re: run fakecommand when client joins a team
Reply With Quote #5

it should
__________________
8guawong is offline
Oylsister
Senior Member
Join Date: Aug 2019
Location: KhonKaen, Thailand
Old 11-07-2019 , 09:15   Re: run fakecommand when client joins a team
Reply With Quote #6

So if I want to set a timer, I have to change it on this line right?

Code:
  if(!IsPlayerAlive(client))
        CreateTimer(4.0, Timer_ZSpawn, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
Oylsister is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 11-07-2019 , 09:22   Re: run fakecommand when client joins a team
Reply With Quote #7

Quote:
Originally Posted by Oylsister View Post
So if I want to set a timer, I have to change it on this line right?

Code:
  if(!IsPlayerAlive(client))
        CreateTimer(4.0, Timer_ZSpawn, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
Yes
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
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 11:58.


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