PDA

View Full Version : [TF2] Exec code on a player that carry item_teamflag


Michalplyoutube
10-18-2014, 15:46
By that i mean how do i run a code to item_teamflag carrier
I would need an example

Oshizu
10-18-2014, 16:56
As an example:

public OnPluginsStart()
{
HookEvent("teamplay_flag_event", EventHook_FlagStuff);
return;
}

public EventHook_FlagStuff(Handle:event, const String:name[], bool:dontBroadcast)
{
if (GetEventInt(event, "eventtype") == TF_FLAGEVENT_PICKEDUP)
{
new client = GetEventInt(event, "player");
SetEntProp(client, Prop_Send, "m_bGlowEnabled", 1);
}
return;
}


I'd personally suggest you reading up those pages:
https://wiki.alliedmods.net/Category:Sourcemod_scripting
https://sm.alliedmods.net/api/
And for Events: https://wiki.alliedmods.net/Team_Fortress_2_Events
You seem to be doing big project the more you know the better :D

Dr. Greg House
10-18-2014, 23:17
whats that return ocd about?

Michalplyoutube
10-19-2014, 04:47
As an example:

public OnPluginsStart()
{
HookEvent("teamplay_flag_event", EventHook_FlagStuff);
return;
}

public EventHook_FlagStuff(Handle:event, const String:name[], bool:dontBroadcast)
{
if (GetEventInt(event, "eventtype") == TF_FLAGEVENT_PICKEDUP)
{
new client = GetEventInt(event, "player");
SetEntProp(client, Prop_Send, "m_bGlowEnabled", 1);
}
return;
}
I'd personally suggest you reading up those pages:
https://wiki.alliedmods.net/Category:Sourcemod_scripting
https://sm.alliedmods.net/api/
And for Events: https://wiki.alliedmods.net/Team_Fortress_2_Events
You seem to be doing big project the more you know the better :D

You're right i m bringing back a plugin you will see wich one

Oshizu
10-19-2014, 08:25
whats that return ocd about?

I ain't sure
I've used rswallen's code :bee:

public OnPluginsStart()
{
HookEvent("teamplay_flag_event", EventHook_FlagStuff);
return;
}

public EventHook_FlagStuff(Handle:event, const String:name[], bool:dontBroadcast)
{
if (GetEventInt(event, "eventtype") == TF_FLAGEVENT_PICKEDUP)
{
// a flag was picked up
}
return;
}

Michalplyoutube
10-19-2014, 09:04
That code worked ealier

Michalplyoutube
10-19-2014, 11:46
As an example:

public OnPluginsStart()
{
HookEvent("teamplay_flag_event", EventHook_FlagStuff);
return;
}

public EventHook_FlagStuff(Handle:event, const String:name[], bool:dontBroadcast)
{
if (GetEventInt(event, "eventtype") == TF_FLAGEVENT_PICKEDUP)
{
new client = GetEventInt(event, "player");
SetEntProp(client, Prop_Send, "m_bGlowEnabled", 1);
}
return;
}
I'd personally suggest you reading up those pages:
https://wiki.alliedmods.net/Category:Sourcemod_scripting
https://sm.alliedmods.net/api/
And for Events: https://wiki.alliedmods.net/Team_Fortress_2_Events
You seem to be doing big project the more you know the better :D

How do i transfer that client index to a timer?

Because i would use it somewhere else besides the event that is hooked to i would like to assing new client = GetEventInt(event, "player"); to that timer to know wich player should get this addcond
public Action:Timer_bombst1(Handle:timer)
{
// Do whatever this timer is supposed to do
TF2_AddCondition(client, TFCond_DefenseBuffNoCritBlock, TFCondDuration_Infinite);
PrecacheSnd( BOMB_SND_STAGEALERT );
EmitSoundToAll( BOMB_SND_STAGEALERT, client, SNDCHAN_STATIC, 125 );
g_hbombs1 = INVALID_HANDLE;
return Plugin_Handled;
}

Oshizu
10-19-2014, 12:26
That would be this:

CreateTimer(15.0, Timer_bombst1, client);
...
public Action:Timer_bombst1(Handle:timer, any:client)
...

Michalplyoutube
10-19-2014, 12:44
That would be this:

CreateTimer(15.0, Timer_bombst1, client);
...
public Action:Timer_bombst1(Handle:timer, any:client)
...


Thanks without you I wouldn't made bomb upgrades till next week you're credit to me

Dr. Greg House
10-19-2014, 12:45
pls dont

ddhoward
10-19-2014, 14:20
That would be this:

CreateTimer(15.0, Timer_bombst1, client);
...
public Action:Timer_bombst1(Handle:timer, any:client)
...


Phase do not suggest bad code to newbies.

You MUST pass the client's userID instead of his index. Otherwise if that player disconnects and someone else connects to the same slot, your code will affect the wrong player.

Michalplyoutube
10-19-2014, 14:53
Changes reverted.
Thanks for the info