|
AlliedModders Donor
|
03-25-2021
, 19:31
Re: player_spawn - fails to keep setting after respawn.
|
#8
|
Quote:
Originally Posted by ThatKidWhoGames
PHP Code:
#pragma semicolon 1
#include <sourcemod>
bool g_bEnableKson[MAXPLAYERS + 1];
public void OnPluginStart() { RegAdminCmd("sm_kson", Cmd_Enable, ADMFLAG_CUSTOM6); HookEvent("player_spawn", Event_PlayerSpawn); }
public void OnClientPutInServer(int client) { g_bEnableKson[client] = false; }
public void OnClientPostAdminCheck(int client) { g_bEnableKson[client] = CheckCommandAccess(client, “sm_kson”, ADMFLAG_CUSTOM6); }
public Action Cmd_Enable(int client, int args) { if (client <= 0 || client > MaxClients || !IsClientInGame(client)) { return Plugin_Handled; } g_bEnableKson[client] = !g_bEnableKson[client]; if (g_bEnableKson[client]) { SetEntProp(client, Prop_Send, "m_nStreaks", 100); } return Plugin_Handled; }
public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast) { int client = GetClientOfUserId(event.GetInt("userid"));
if (g_bEnableKson[client]) { SetEntProp(client, Prop_Send, "m_nStreaks", 100); } }
|
Quote:
Originally Posted by Bacardi
Try this :/
Code:
#pragma semicolon 1
#include <sourcemod>
bool g_bEnableKson[MAXPLAYERS + 1];
public void OnPluginStart()
{
RegAdminCmd("sm_kson", Cmd_Enable, ADMFLAG_CUSTOM6);
HookEvent("player_spawn", Event_PlayerSpawn);
}
public void OnClientPostAdminCheck(int client)
{
g_bEnableKson[client] = CheckCommandAccess(client, "sm_kson", ADMFLAG_CUSTOM6);
}
public Action Cmd_Enable(int client, int args)
{
if (client <= 0 || client > MaxClients || !IsClientInGame(client))
{
return Plugin_Handled;
}
g_bEnableKson[client] = !g_bEnableKson[client];
if (g_bEnableKson[client])
{
SetEntProp(client, Prop_Send, "m_nStreaks", 100);
}
return Plugin_Handled;
}
public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (g_bEnableKson[client])
{
SetEntProp(client, Prop_Send, "m_nStreaks", 100);
}
}
|
Both scripts work, but there is a problem.
Example:
A player joins the server, however streak effects failed to be applied immediately, unless player respawns/dies.
Can this be fixed so that the streak effects is instantly applied? rather than waiting to respawn.
__________________
Last edited by ph; 03-25-2021 at 21:02.
|
|
|
|