PDA

View Full Version : Timer error: Undefined symbol?


Ibanezez
10-04-2014, 16:20
Section of my code:


CreateTimer(5.0, fivesecondtimer);
TF2_RespawnPlayer(client);
PrintToChat(client, "You have been respawned after 5 seconds!


I'm getting this error:
error 017: undefined symbol "fivesecondtimer"

Not sure how to fix this. Does anyone have any ideas?

LambdaLambda
10-04-2014, 16:36
You are missing the action.

public Action:fivesecondtimer(Handle:timer)
{

}

TnTSCS
10-04-2014, 17:18
Ibanezez:

You need to use the SourceMod Wiki more.

https://wiki.alliedmods.net/Timers_(SourceMod_Scripting) <-- for timer help

TnTSCS
10-04-2014, 17:23
Sounds like you want to respawn a player after 5 seconds of death, right?


public YourDeathCallback(client) // Either with event or some other method, up to you.
{
CreateTimer(5.0, RespawnPlayer, GetClientSerial(client)); // You could also use GetClientUserId(client)
}

public Action:RespawnPlayer(Handle:timer, any:serial)
{
new client = GetClientFromSerial(serial); // Validate the client serial

if (client == 0 || IsPlayerAlive(client)) // The serial is no longer valid, the player must have disconnected or the player is already alive.
{
return Plugin_Stop; //Maybe Plugin_Handled;?
}

TF2_RespawnPlayer(client);
PrintToChat(client, "You have been respawned after 5 seconds!");

return Plugin_Handled;
}


The above uses GetClientSerial (https://sm.alliedmods.net/api/index.php?fastload=show&id=72&) and GetClientFromSerial (https://sm.alliedmods.net/api/index.php?fastload=show&id=73&), which is a good option when using timers that act on clients/players. Timer code is just a modified version of what's posted here (https://wiki.alliedmods.net/Timers_(SourceMod_Scripting)#Passing_Data), tailored towards your needs/request.

Powerlord
10-04-2014, 17:49
Why not just use mp_disable_respawn_times 1? For all gamemodes except Arena and MvM, this will respawn players as soon as the deathcam goes away (which is roughly 5 seconds).

Incidentally, Valve made it mandatory (https://support.steampowered.com/kb_article.php?ref=2825-AFGJ-3513#truth) to set sv_tags on plugins that change respawn times. Failure to do so can get you removed not just from QuickPlay pools, but also from the Master Server List (which controls servers that show up in the Internet tab of the server browser). Oh, and servers that do this are also banned from the Halloween gift drops since they're also part of the QuickPlay registration system.

Ibanezez
10-04-2014, 18:08
This is part of a bigger plugin, that respawns a player after they do the spycrab taunt for 5 seconds. The whole area of the timer would be this:

new client = GetEntPropEnt(entity, Prop_Data, "m_hOwner");
CreateTimer(5.0, fivesecondtimer);
TF2_RespawnPlayer(client);
PrintToChat(client, "You have spycrabbed!");