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

Player spawn refuses to work (and MapStart)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shadow Of Death @ CSB
Junior Member
Join Date: Sep 2010
Old 09-10-2010 , 19:50   Player spawn refuses to work (and MapStart)
Reply With Quote #1

That's it. As i told (https://forums.alliedmods.net/showth...21#post1294921), i fixed the tracerbeam. But now then i tried to put the beginning action into the player_spawn hook and now any function inside the player_spawn won't work anymore... So i was thinking you guys could help me out!

This is the 'Spawn' hook, a quote of my script:
Code:
public Action:Spawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new cliente = GetClientOfUserId(GetEventInt(event, "userid"));
    if (!IsFakeClient(cliente) && IsClientInGame(cliente))
    {
        decl String:overlay[PLATFORM_MAX_PATH];
        GetConVarString(cvarOver, overlay, sizeof(overlay));
        ClientCommand(cliente, "r_screenoverlay \"%s\"", overlay);
        CreateTimer(30.0, OverlayTemporizador, cliente, TIMER_REPEAT);
    }
    new bool:bhopativado = GetConVarBool(cvarBAtivado);
    if (bhopativado)
    {
        new transparencia = GetConVarInt(cvarTran);
        if (transparencia != 255)
        {
            SetEntityRenderMode(cliente, RENDER_TRANSCOLOR);
            SetEntityRenderColor(cliente, 255, 255, 255, transparencia);
        }
    }
    if (GetUserAdmin(cliente) != INVALID_ADMIN_ID)
    {
        tracer[cliente] = true;
        CreateTimer(1.0, Tracer, cliente, TIMER_REPEAT);
    }
    return Plugin_Continue;
}
-> Edit now, OnMapStart also doesn't want to work anymore:
Code:
public OnMapStart()
{
    decl String:buffer[255], String:buffer_f[PLATFORM_MAX_PATH];
    GetConVarString(cvarSprite, buffer, sizeof(buffer));
    Format(buffer_f, sizeof(buffer_f), "%s.vmt", buffer);
    if (FileExists(buffer_f))
    {
        CSBsprite = PrecacheModel(buffer_f);
        PrecacheDecal(buffer_f, true);
        AddFileToDownloadsTable(buffer_f);
        PrintToServer("Foi adicionado %s para a lista de downloads!", buffer_f);
    }
    if (PrecacheDecal(buffer_f, true) == 0 || !FileExists(buffer_f))
    {
        PrintToServer("Nao foi possivel adicionar %s para a lista de downloads!", buffer_f);
        CSBsprite = 0;
    }
    Format(buffer_f, sizeof(buffer_f), "%s.vtf", buffer);
    if (FileExists(buffer_f))
    {
        PrecacheDecal(buffer_f, true);
        AddFileToDownloadsTable(buffer_f);
        PrintToServer("Foi adicionado %s para a lista de downloads!", buffer_f);
    }
    if (PrecacheDecal(buffer_f, true) == 0 || !FileExists(buffer_f))
        PrintToServer("Nao foi possivel adicionar %s para a lista de downloads!", buffer_f);
    decl String:overlay[255], String:overlay_f[PLATFORM_MAX_PATH];
    GetConVarString(cvarOver, overlay, sizeof(overlay));
    Format(overlay_f, sizeof(overlay_f), "materials/%s.vmt", overlay);
    if (FileExists(overlay_f))
    {
        PrecacheDecal(overlay_f, true);
        AddFileToDownloadsTable(overlay_f);
        PrintToServer("Foi adicionado %s para a lista de downloads!", overlay_f);
    }
    if (PrecacheDecal(overlay_f, true) == 0 || !FileExists(overlay_f))
        PrintToServer("Nao foi possivel adicionar %s para a lista de downloads!", overlay_f);
    Format(overlay_f, sizeof(overlay_f), "materials/%s.vtf", overlay_f);
    if (FileExists(overlay_f))
    {
        PrecacheDecal(overlay_f, true);
        AddFileToDownloadsTable(overlay_f);
        PrintToServer("Foi adicionado %s para a lista de downloads!", overlay_f);
    }
    if (PrecacheDecal(overlay_f, true) == 0 || !FileExists(overlay_f))
        PrintToServer("Nao foi possivel adicionar %s para a lista de downloads!", overlay_f);
}
By now, Thy again.
Shadow Of Death @ CSB is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 09-10-2010 , 20:01   Re: Player spawn refuses to work (and MapStart)
Reply With Quote #2

Are you getting any errors in your logs that would cause the events to drop out early? I don't see anything obviously wrong with the code.
__________________
thetwistedpanda is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 09-10-2010 , 20:02   Re: Player spawn refuses to work (and MapStart)
Reply With Quote #3

I dont know, but you must be doing something wrong. Unless CSS doesnt have MapStart forward(unlikely) it should work. I dont see anything wrong with the spawn hook either(besides the incorrect Action: part). Since you didnt post any other code, im gonna guess you hooked it correctly............

Also, you dont need IsClientInGame check for the spawn hook, only alive check and = 0 check.
__________________

Last edited by retsam; 09-10-2010 at 20:08.
retsam is offline
Shadow Of Death @ CSB
Junior Member
Join Date: Sep 2010
Old 09-10-2010 , 20:36   Re: Player spawn refuses to work (and MapStart)
Reply With Quote #4

No, im not getting any errors, and it is loading with any error in server console.

The hook i did is this (onpluginstart):
Code:
HookEvent("player_spawn", Spawn);
Actually if i take off
Code:
    if (GetUserAdmin(cliente) != INVALID_ADMIN_ID)     {         tracer[cliente] = true;         CreateTimer(1.0, Tracer, cliente, TIMER_REPEAT);     }
it will actually work (i'm close to be pretty sure of it, i tested).
One this i know 100% sure is that CS:S has OnMapStart() native... Tell what other part you would like to analyze and i will post it, or whatever every script. Ive been searching for an error and i dont really know what it is. I tested it in my hl2:dm homemade server and the profission 24h server (css).

PS: Ty retsam for the Action: hint
-hope to get answers
Shadow Of Death @ CSB is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 09-10-2010 , 21:29   Re: Player spawn refuses to work (and MapStart)
Reply With Quote #5

You do realize youre code for "tracer" timer is only set for people with an admin flag right?

Also, make sure youre killing both of those repeating timers there....I guess in CSS you only spawn once per round or whatever but...make sure youre killing the timers before they spawn again or thats very very bad.
__________________

Last edited by retsam; 09-10-2010 at 21:32.
retsam is offline
Shadow Of Death @ CSB
Junior Member
Join Date: Sep 2010
Old 09-10-2010 , 21:42   Re: Player spawn refuses to work (and MapStart)
Reply With Quote #6

Yes (for all), actually i did, besides the "OverlayTemporizador" timer, that is not supoused to stop:
Code:
public Action:OverlayTemporizador(Handle:timer, any:Client)
{
    decl String:overlay[PLATFORM_MAX_PATH];
    GetConVarString(cvarOver, overlay, sizeof(overlay));
    ClientCommand(Client, "r_screenoverlay \"%s\"", overlay);
    return Plugin_Continue;
}
It is just a simple timer to force players keep with the overlay in the screen... Anyways it dunno explain why the OnMapStart is not working...
Shadow Of Death @ CSB is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 09-10-2010 , 21:43   Re: Player spawn refuses to work (and MapStart)
Reply With Quote #7

I know you probably don't want to, but if you posted the entire code it would be easier for people to help you in the debugging process.
__________________
thetwistedpanda is offline
Shadow Of Death @ CSB
Junior Member
Join Date: Sep 2010
Old 09-10-2010 , 21:55   Re: Player spawn refuses to work (and MapStart)
Reply With Quote #8

Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1

#define CTAG "%t"
#define YELLOW 0x01
#define LIGHTGREEN 0x03
#define GREEN 0x04
new Handle:cvarOver = INVALID_HANDLE;
new Handle:cvarTran = INVALID_HANDLE;
new Handle:cvarArma = INVALID_HANDLE;
new Handle:cvarSprite = INVALID_HANDLE;
new Handle:cvarBAtivado = INVALID_HANDLE;
new Handle:cvarScoutlimite = INVALID_HANDLE;
new bool:usado[MAXPLAYERS+1] = false;
new bool:pativado[MAXPLAYERS+1] = false;
new bool:tracer[MAXPLAYERS+1] = false;
new Float:cord[MAXPLAYERS+1][3];
new pulos[MAXPLAYERS+1];
new scouts[MAXPLAYERS+1];
new CSBsprite;

public Plugin:myinfo =
{
    name = "SODExtencao",
    author = "Shadow_of_Death",
    description = "Comandos diversos para servidor de bhop e deathrun",
    version = "1",
    url = "http://www.CSBrazucas.com/"
};

public OnPluginStart()
{
    LoadTranslations("common.phrases");
    LoadTranslations("sodext.phrases");
    HookEvent("player_jump", Pulos);
    HookEvent("player_spawn", Spawn);
    HookEvent("player_blind", Flash);
    cvarOver = CreateConVar("sm_sod_overlay", "overlays/csb/csblogo", "Overlay mostrado aos clientes", FCVAR_PLUGIN);
    cvarTran = CreateConVar("sm_sod_trans", "100", "Transparencia dos personagens. 0==Transparente, 255==Opaco", FCVAR_PLUGIN, true, 0.0, true, 255.0);
    cvarArma = CreateConVar("sm_sod_arma", "scout", "Arma a ser dada ao usuario: <arma>", FCVAR_PLUGIN);
    cvarSprite = CreateConVar("sm_sod_tracer", "materials/Sprites/CSBrazucas/Tracer_v", "Material do tracer a ser usado", FCVAR_PLUGIN);
    cvarScoutlimite = CreateConVar("sm_scout_limite", "5", "Numero limite de scouts para o usuario: 0==Infinito", FCVAR_PLUGIN, true, 0.0, false);
    cvarBAtivado = CreateConVar("sm_bhop_ativado", "0", "USO AUTOMATICO. Ativa comandos de bhop, automatico para mapas bhop", FCVAR_PLUGIN, true, 0.0, true, 1.0);
    RegConsoleCmd("sm_scout", C_Scout, "Da uma scout para o usuario, uso em servidores de Bhop");
    RegConsoleCmd("sm_bhop", C_Bhop, "Abre o menu de Bhop");
    RegConsoleCmd("sm_salv", C_Salvar, "Salvar cordenadas atuais");
    RegConsoleCmd("sm_tele", C_Tele, "Teleportar para a cordenada salva");
    RegConsoleCmd("sm_info", C_PularVelocidade, "Ativar/Desativar o painel de informacoes");
    RegConsoleCmd("sm_vclip", C_VClip, "Desativa NoClip silencioso/normal de si mesmo, uso de qualquer usuario");
    RegAdminCmd("sm_sclip", C_NoClip, ADMFLAG_KICK, "Ativar/Desativar Noclip silencioso aos jogadores: sm_sclip <alvo1>...");
    AutoExecConfig(true, "Bhop_SODExt");
}

public OnConfigsExecuted()
{
    decl String:mapa[128];
    GetCurrentMap(mapa, sizeof(mapa));
    if (strncmp(mapa, "bhop_", 5, false) == 0)
    {
        SetConVarInt(cvarBAtivado, 1);
    } else {
        SetConVarInt(cvarBAtivado, 0);
    }
}

public OnMapStart()
{
    decl String:buffer[255], String:buffer_f[PLATFORM_MAX_PATH];
    GetConVarString(cvarSprite, buffer, sizeof(buffer));
    Format(buffer_f, sizeof(buffer_f), "%s.vmt", buffer);
    if (FileExists(buffer_f))
    {
        CSBsprite = PrecacheModel(buffer_f);
        PrecacheDecal(buffer_f, true);
        AddFileToDownloadsTable(buffer_f);
        PrintToServer("Foi adicionado %s para a lista de downloads!", buffer_f);
    }
    if (PrecacheDecal(buffer_f, true) == 0 || !FileExists(buffer_f))
    {
        PrintToServer("Nao foi possivel adicionar %s para a lista de downloads!", buffer_f);
        CSBsprite = 0;
    }
    Format(buffer_f, sizeof(buffer_f), "%s.vtf", buffer);
    if (FileExists(buffer_f))
    {
        PrecacheDecal(buffer_f, true);
        AddFileToDownloadsTable(buffer_f);
        PrintToServer("Foi adicionado %s para a lista de downloads!", buffer_f);
    }
    if (PrecacheDecal(buffer_f, true) == 0 || !FileExists(buffer_f))
        PrintToServer("Nao foi possivel adicionar %s para a lista de downloads!", buffer_f);
    decl String:overlay[255], String:overlay_f[PLATFORM_MAX_PATH];
    GetConVarString(cvarOver, overlay, sizeof(overlay));
    Format(overlay_f, sizeof(overlay_f), "materials/%s.vmt", overlay);
    if (FileExists(overlay_f))
    {
        PrecacheDecal(overlay_f, true);
        AddFileToDownloadsTable(overlay_f);
        PrintToServer("Foi adicionado %s para a lista de downloads!", overlay_f);
    }
    if (PrecacheDecal(overlay_f, true) == 0 || !FileExists(overlay_f))
        PrintToServer("Nao foi possivel adicionar %s para a lista de downloads!", overlay_f);
    Format(overlay_f, sizeof(overlay_f), "materials/%s.vtf", overlay_f);
    if (FileExists(overlay_f))
    {
        PrecacheDecal(overlay_f, true);
        AddFileToDownloadsTable(overlay_f);
        PrintToServer("Foi adicionado %s para a lista de downloads!", overlay_f);
    }
    if (PrecacheDecal(overlay_f, true) == 0 || !FileExists(overlay_f))
        PrintToServer("Nao foi possivel adicionar %s para a lista de downloads!", overlay_f);
}

public OnClientConnected(Client)
{
    tracer[Client] = false;
    pativado[Client] = false;
    usado[Client] = false;
    pulos[Client] = 0;
    scouts[Client] = 0;
}

public Action:Tracer(Handle:time, any:Client)
{
    if (tracer[Client])
    {
        TE_SetupBeamFollow(Client, CSBsprite, 0, 2.0, 10.0, 100.0, 70, {0,129,255,100});
        TE_SendToAll();
        return Plugin_Continue;
    } else {
        return Plugin_Stop;
    }
}

public Spawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new cliente = GetClientOfUserId(GetEventInt(event, "userid"));
    decl String:overlay[PLATFORM_MAX_PATH];
    GetConVarString(cvarOver, overlay, sizeof(overlay));
    ClientCommand(cliente, "r_screenoverlay \"%s\"", overlay);
    CreateTimer(30.0, OverlayTemporizador, cliente, TIMER_REPEAT);
    new bool:bhopativado = GetConVarBool(cvarBAtivado);
    if (bhopativado)
    {
        new transparencia = GetConVarInt(cvarTran);
        if (transparencia != 255)
        {
            SetEntityRenderMode(cliente, RENDER_TRANSCOLOR);
            SetEntityRenderColor(cliente, 255, 255, 255, transparencia);
        }
    }
    if (GetUserAdmin(cliente) != INVALID_ADMIN_ID)
    {
        tracer[cliente] = true;
        CreateTimer(1.0, Tracer, cliente, TIMER_REPEAT);
    }
    return Plugin_Continue;
}

public Action:Flash(Handle:event, const String:name[], bool:dontbroadcast)
{
    new bool:bhopativado = GetConVarBool(cvarBAtivado);
    if (bhopativado)
    {
        new cliente = GetClientOfUserId(GetEventInt(event, "userid"));
        SetEntDataFloat(cliente, FindSendPropOffs("CCSPlayer", "m_flFlashMaxAlpha"), 0.0);
    }
    return Plugin_Continue;
}

public Action:Pulos(Handle:event, const String:name[], bool:dontBroadcast)
{
    new cliente = GetClientOfUserId(GetEventInt(event, "userid"));
    pulos[cliente]++;
    return Plugin_Continue;
}

public Action:C_PularVelocidade(Client, args)
{
    if (!pativado[Client])
    {
        pativado[Client] = true;
        CreateTimer(1.0, PuloVelocidade, Client, TIMER_REPEAT);
        PrintToChat(Client, CTAG, "PularVelocidadeAtivado", GREEN, YELLOW);
    } else {
        pativado[Client] = false;
        PrintToChat(Client, CTAG, "PularVelocidadeDesativado", GREEN, YELLOW);
    }
    return Plugin_Handled;
}

public Action:PuloVelocidade(Handle:timer, any:Client)
{
    if (pativado[Client])
    {
        new Float:vec[3];
        GetEntPropVector(Client, Prop_Data, "m_vecVelocity", vec);
        new velocidade = RoundToFloor(SquareRoot(Pow(vec[0],2.0)+Pow(vec[1],2.0)+Pow(vec[2],2.0))*0.06858);
        PrintHintText(Client, "Pulos executados: %i | Velocidade atual: %iKm/H", pulos[Client], velocidade);
        return Plugin_Continue;
    } else {
        return Plugin_Stop;
    }
}

public Action:OverlayTemporizador(Handle:timer, any:Client)
{
    decl String:overlay[PLATFORM_MAX_PATH];
    GetConVarString(cvarOver, overlay, sizeof(overlay));
    ClientCommand(Client, "r_screenoverlay \"%s\"", overlay);
    return Plugin_Continue;
}

public Action:C_Scout(Client, args)
{
    new bool:bhopativado = GetConVarBool(cvarBAtivado);
    if (bhopativado)
    {
        new String:arma[20], String:nomearma[13];
        GetConVarString(cvarArma, nomearma, sizeof(nomearma));
        Format(arma, sizeof(arma), "weapon_%s", nomearma);
        new limite = GetConVarInt(cvarScoutlimite);
        if (scouts[Client] < limite || limite == 0)
        {
            GivePlayerItem(Client, arma);
            scouts[Client]++;
            PrintToChat(Client, CTAG, "Dada", GREEN, YELLOW, nomearma, limite);
        } else {
            PrintToChat(Client, CTAG, "LimiteScout", GREEN, YELLOW, limite, nomearma);
        }
    } else {
        PrintToChat(Client, CTAG, "Desativado", GREEN, YELLOW);
    }
    return Plugin_Handled;
}

public Action:C_Bhop(Client, args)
{
    new bool:bhopativado = GetConVarBool(cvarBAtivado);
    if (bhopativado)
    {
        BhopMenu(Client);
    } else {
        PrintToChat(Client, CTAG, "Desativado", GREEN, YELLOW);
    }
    return Plugin_Handled;
}

public BhopMenu(Client)
{
    new Handle:bmenu = CreateMenu(hbmenu);
    SetMenuTitle(bmenu, "[CSBrazucas.com] Bhop");
    AddMenuItem(bmenu, "Salvar", "Salva as cordenadas atuais");
    AddMenuItem(bmenu, "Teleportar", "Teleporta para as cordenadas salvas");
    AddMenuItem(bmenu, "Pulos e Velocidade", "Mostra a velocidade atual e a quantidade de pulos");
    AddMenuItem(bmenu, "Tempo", "Mostrar o tempo conectado ao servidor");
    AddMenuItem(bmenu, "Scout", "Pedir uma scout");
    AddMenuItem(bmenu, "Musica", "Parar a musica de vinda ao server");
    SetMenuExitButton(bmenu, true);
    SetMenuOptionFlags(bmenu, MENUFLAG_BUTTON_EXIT);
    DisplayMenu(bmenu, Client, MENU_TIME_FOREVER);
}

public hbmenu(Handle:menu, MenuAction:action, Client, selec)
{
    if (action == MenuAction_Select)
    {
        switch (selec)
        {
            case 0: SalvarCordenadas(Client);
            case 1: TeleportarCordenadas(Client);
            case 2: ClientCommand(Client, "sm_info");
            case 3: MostrarTempo(Client);
            case 4: ClientCommand(Client, "sm_scout");
            case 5: ClientCommand(Client, "play UI/buttonclick.wav");
        }
        BhopMenu(Client);
    } else if (action == MenuAction_End)
        CloseHandle(menu);
}

public Action:C_Salvar(Client, args)
{
    new bool:bhopativado = GetConVarBool(cvarBAtivado);
    if (bhopativado)
    {
        SalvarCordenadas(Client);
    } else {
        PrintToChat(Client, CTAG, "Desativado", GREEN, YELLOW);
    }
    return Plugin_Handled;
}

public Action:C_Tele(Client, args)
{
    new bool:bhopativado = GetConVarBool(cvarBAtivado);
    if (bhopativado)
    {
        TeleportarCordenadas(Client);
    } else {
        PrintToChat(Client, CTAG, "Desativado", GREEN, YELLOW);
    }
    return Plugin_Handled;
}

SalvarCordenadas(Client)
{
    new Float:vec[3];
    GetEntPropVector(Client, Prop_Data, "m_vecVelocity", vec);
    new velocidade = RoundToFloor(SquareRoot(Pow(vec[0],2.0)+Pow(vec[1],2.0)+Pow(vec[2],2.0))*0.06858);
    if (velocidade == 0 && GetEntDataEnt2(Client, FindSendPropOffs("CBasePlayer", "m_hGroundEntity")) != -1)
    {
        usado[Client] = true;
        GetClientAbsOrigin(Client, cord[Client]);
        PrintToChat(Client, CTAG, "Salvo", GREEN, YELLOW);
    } else if (GetEntDataEnt2(Client, FindSendPropOffs("CBasePlayer", "m_hGroundEntity")) == -1)
    {
        PrintToChat(Client, CTAG, "Chao", GREEN, YELLOW);
    } else if (velocidade != 0)
    {
        PrintToChat(Client, CTAG, "Velocidade", GREEN, YELLOW);
    }
}

TeleportarCordenadas(Client)
{
    if (usado[Client])
    {
        TeleportEntity(Client, cord[Client], NULL_VECTOR, NULL_VECTOR);
    } else {
        PrintToChat(Client, CTAG, "NaoSalvo", GREEN, YELLOW);
    }
}

public Action:C_VClip(Client, args)
{
    new MoveType:movetype = GetEntityMoveType(Client);
    if (movetype == MOVETYPE_NOCLIP)
    {
        SetEntityMoveType(Client, MOVETYPE_WALK);
        SetEntityRenderFx(Client, RENDERFX_NONE);
    } else {
        PrintToChat(Client, CTAG, "Caminhando", GREEN, YELLOW);
    }
    return Plugin_Handled;
}

public Action:C_NoClip(Client, args)
{
    new num = GetCmdArgs();
    if (num > 0)
    {
        new String:target_name[MAX_TARGET_LENGTH], String:yoo[32];
        new target_list[MAXPLAYERS], target_count;
        new bool:tn_is_ml;
        GetCmdArg(1, yoo, sizeof(yoo));
        if ((target_count = ProcessTargetString(
            yoo,
            Client,
            target_list,
            MAXPLAYERS,
            COMMAND_FILTER_ALIVE,
            target_name,
            sizeof(target_name),
            tn_is_ml)) <= 0)
        {
            ReplyToTargetError(Client, target_count);
            return Plugin_Handled;
        }
        for (new i = 0; i < target_count; i++)
        {
            SNoClip(Client, target_list[i]);
        }
    } else {
        SNoClip(Client, Client);
    }
    return Plugin_Handled;
}

SNoClip(Client, alvo)
{
    new MoveType:movetype = GetEntityMoveType(alvo);
    if (movetype != MOVETYPE_NOCLIP)
    {
        if (Client != alvo)
        {
            new String:nomeum[MAX_NAME_LENGTH], String:nomedois[MAX_NAME_LENGTH];
            GetClientName(Client, nomeum, sizeof(nomeum));
            GetClientName(alvo, nomedois, sizeof(nomedois));
            PrintToChat(alvo, CTAG, "RecebeuClip", GREEN, YELLOW, nomeum);
            PrintToChat(Client, CTAG, "DadoClip", GREEN, YELLOW, nomedois);
            PrintToChat(alvo, CTAG, "Dica", GREEN, YELLOW);
        } else {
            PrintToChat(Client, CTAG, "Proprio", GREEN, YELLOW);
        }
        SetEntityMoveType(alvo, MOVETYPE_NOCLIP);
        SetEntityRenderFx(alvo, RENDERFX_FADE_FAST);
    } else {
        SetEntityMoveType(alvo, MOVETYPE_WALK);
        SetEntityRenderFx(alvo, RENDERFX_NONE);
    }
}

MostrarTempo(Client)
{
    new total = RoundToFloor(GetClientTime(Client)/60.00);
    PrintCenterText(Client, "Voce esta conectado ao servidor por %i minutos (inteiros)", total);
}
sry
Shadow Of Death @ CSB is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 09-10-2010 , 22:07   Re: Player spawn refuses to work (and MapStart)
Reply With Quote #9

Quote:
Originally Posted by Shadow Of Death @ CSB View Post
Yes (for all), actually i did, besides the "OverlayTemporizador" timer, that is not supoused to stop:
Code:
public Action:OverlayTemporizador(Handle:timer, any:Client)
{
    decl String:overlay[PLATFORM_MAX_PATH];
    GetConVarString(cvarOver, overlay, sizeof(overlay));
    ClientCommand(Client, "r_screenoverlay \"%s\"", overlay);
    return Plugin_Continue;
}
It is just a simple timer to force players keep with the overlay in the screen... Anyways it dunno explain why the OnMapStart is not working...

Yes, but look at your code. THats fine, but the timer still has to be killed before its created again.

Its not supposed to be stopped, but you have no checks in there to make sure it doesnt create another timer..... Get it?

Nor are you killing the timers on disconnect, which is going to give you memory leaks or at the very least errors.

Youre also missing standard checks in there too....(ingame,alive, etc)

You either need ingame,alive checks in the timer then kill it if not, or you need to define handles for those timers and kill them manually on disconnect.
__________________

Last edited by retsam; 09-10-2010 at 22:13.
retsam is offline
Shadow Of Death @ CSB
Junior Member
Join Date: Sep 2010
Old 09-10-2010 , 22:27   Re: Player spawn refuses to work (and MapStart)
Reply With Quote #10

Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1

#define CTAG "%t"
#define YELLOW 0x01
#define LIGHTGREEN 0x03
#define GREEN 0x04
new Handle:cvarOver = INVALID_HANDLE;
new Handle:cvarTran = INVALID_HANDLE;
new Handle:cvarArma = INVALID_HANDLE;
new Handle:cvarSprite = INVALID_HANDLE;
new Handle:cvarBAtivado = INVALID_HANDLE;
new Handle:cvarScoutlimite = INVALID_HANDLE;
new bool:usado[MAXPLAYERS+1] = false;
new bool:pativado[MAXPLAYERS+1] = false;
new bool:tracer[MAXPLAYERS+1] = false;
new bool:matover[MAXPLAYERS+1] = false;
new Float:cord[MAXPLAYERS+1][3];
new pulos[MAXPLAYERS+1];
new scouts[MAXPLAYERS+1];
new CSBsprite;

public Plugin:myinfo =
{
    name = "SODExtencao",
    author = "Shadow_of_Death",
    description = "Comandos diversos para servidor de bhop e deathrun",
    version = "1",
    url = "http://www.CSBrazucas.com/"
};

public OnPluginStart()
{
    LoadTranslations("common.phrases");
    LoadTranslations("sodext.phrases");
    HookEvent("player_jump", Pulos);
    HookEvent("player_spawn", Spawn);
    HookEvent("player_blind", Flash);
    cvarOver = CreateConVar("sm_sod_overlay", "overlays/csb/csblogo", "Overlay mostrado aos clientes", FCVAR_PLUGIN);
    cvarTran = CreateConVar("sm_sod_trans", "100", "Transparencia dos personagens. 0==Transparente, 255==Opaco", FCVAR_PLUGIN, true, 0.0, true, 255.0);
    cvarArma = CreateConVar("sm_sod_arma", "scout", "Arma a ser dada ao usuario: <arma>", FCVAR_PLUGIN);
    cvarSprite = CreateConVar("sm_sod_tracer", "materials/Sprites/CSBrazucas/Tracer_v", "Material do tracer a ser usado", FCVAR_PLUGIN);
    cvarScoutlimite = CreateConVar("sm_scout_limite", "5", "Numero limite de scouts para o usuario: 0==Infinito", FCVAR_PLUGIN, true, 0.0, false);
    cvarBAtivado = CreateConVar("sm_bhop_ativado", "0", "USO AUTOMATICO. Ativa comandos de bhop, automatico para mapas bhop", FCVAR_PLUGIN, true, 0.0, true, 1.0);
    RegConsoleCmd("sm_scout", C_Scout, "Da uma scout para o usuario, uso em servidores de Bhop");
    RegConsoleCmd("sm_bhop", C_Bhop, "Abre o menu de Bhop");
    RegConsoleCmd("sm_salv", C_Salvar, "Salvar cordenadas atuais");
    RegConsoleCmd("sm_tele", C_Tele, "Teleportar para a cordenada salva");
    RegConsoleCmd("sm_info", C_PularVelocidade, "Ativar/Desativar o painel de informacoes");
    RegConsoleCmd("sm_vclip", C_VClip, "Desativa NoClip silencioso/normal de si mesmo, uso de qualquer usuario");
    RegAdminCmd("sm_sclip", C_NoClip, ADMFLAG_KICK, "Ativar/Desativar Noclip silencioso aos jogadores: sm_sclip <alvo1>...");
    AutoExecConfig(true, "Bhop_SODExt");
}

public OnConfigsExecuted()
{
    decl String:mapa[128];
    GetCurrentMap(mapa, sizeof(mapa));
    if (strncmp(mapa, "bhop_", 5, false) == 0)
    {
        SetConVarInt(cvarBAtivado, 1);
    } else {
        SetConVarInt(cvarBAtivado, 0);
    }
}

public OnMapStart()
{
    decl String:buffer[255], String:buffer_f[PLATFORM_MAX_PATH];
    GetConVarString(cvarSprite, buffer, sizeof(buffer));
    Format(buffer_f, sizeof(buffer_f), "%s.vmt", buffer);
    if (FileExists(buffer_f))
    {
        CSBsprite = PrecacheModel(buffer_f);
        PrecacheDecal(buffer_f, true);
        AddFileToDownloadsTable(buffer_f);
        PrintToServer("Foi adicionado %s para a lista de downloads!", buffer_f);
    }
    if (PrecacheDecal(buffer_f, true) == 0 || !FileExists(buffer_f))
    {
        PrintToServer("Nao foi possivel adicionar %s para a lista de downloads!", buffer_f);
        CSBsprite = 0;
    }
    Format(buffer_f, sizeof(buffer_f), "%s.vtf", buffer);
    if (FileExists(buffer_f))
    {
        PrecacheDecal(buffer_f, true);
        AddFileToDownloadsTable(buffer_f);
        PrintToServer("Foi adicionado %s para a lista de downloads!", buffer_f);
    }
    if (PrecacheDecal(buffer_f, true) == 0 || !FileExists(buffer_f))
        PrintToServer("Nao foi possivel adicionar %s para a lista de downloads!", buffer_f);
    decl String:overlay[255], String:overlay_f[PLATFORM_MAX_PATH];
    GetConVarString(cvarOver, overlay, sizeof(overlay));
    Format(overlay_f, sizeof(overlay_f), "materials/%s.vmt", overlay);
    if (FileExists(overlay_f))
    {
        PrecacheDecal(overlay_f, true);
        AddFileToDownloadsTable(overlay_f);
        PrintToServer("Foi adicionado %s para a lista de downloads!", overlay_f);
    }
    if (PrecacheDecal(overlay_f, true) == 0 || !FileExists(overlay_f))
        PrintToServer("Nao foi possivel adicionar %s para a lista de downloads!", overlay_f);
    Format(overlay_f, sizeof(overlay_f), "materials/%s.vtf", overlay_f);
    if (FileExists(overlay_f))
    {
        PrecacheDecal(overlay_f, true);
        AddFileToDownloadsTable(overlay_f);
        PrintToServer("Foi adicionado %s para a lista de downloads!", overlay_f);
    }
    if (PrecacheDecal(overlay_f, true) == 0 || !FileExists(overlay_f))
        PrintToServer("Nao foi possivel adicionar %s para a lista de downloads!", overlay_f);
}

public OnClientConnected(Client)
{
    tracer[Client] = false;
    pativado[Client] = false;
    usado[Client] = false;
    matover[Client] = false;
    pulos[Client] = 0;
    scouts[Client] = 0;
}

public Action:Tracer(Handle:time, any:Client)
{
    if (tracer[Client])
    {
        TE_SetupBeamFollow(Client, CSBsprite, 0, 2.0, 10.0, 100.0, 70, {0,129,255,100});
        TE_SendToAll();
        return Plugin_Continue;
    } else {
        return Plugin_Stop;
    }
}

public Spawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new cliente = GetClientOfUserId(GetEventInt(event, "userid"));
    decl String:overlay[PLATFORM_MAX_PATH];
    GetConVarString(cvarOver, overlay, sizeof(overlay));
    ClientCommand(cliente, "r_screenoverlay \"%s\"", overlay);
    matover[cliente] = true;
    CreateTimer(30.0, OverlayTemporizador, cliente, TIMER_REPEAT);
    new bool:bhopativado = GetConVarBool(cvarBAtivado);
    if (bhopativado)
    {
        new transparencia = GetConVarInt(cvarTran);
        if (transparencia != 255)
        {
            SetEntityRenderMode(cliente, RENDER_TRANSCOLOR);
            SetEntityRenderColor(cliente, 255, 255, 255, transparencia);
        }
    }
    if (GetUserAdmin(cliente) != INVALID_ADMIN_ID)
    {
        tracer[cliente] = true;
        CreateTimer(1.0, Tracer, cliente, TIMER_REPEAT);
    }
    return Plugin_Continue;
}

public Action:Flash(Handle:event, const String:name[], bool:dontbroadcast)
{
    new bool:bhopativado = GetConVarBool(cvarBAtivado);
    if (bhopativado)
    {
        new cliente = GetClientOfUserId(GetEventInt(event, "userid"));
        SetEntDataFloat(cliente, FindSendPropOffs("CCSPlayer", "m_flFlashMaxAlpha"), 0.0);
    }
    return Plugin_Continue;
}

public Action:Pulos(Handle:event, const String:name[], bool:dontBroadcast)
{
    new cliente = GetClientOfUserId(GetEventInt(event, "userid"));
    pulos[cliente]++;
    return Plugin_Continue;
}

public Action:C_PularVelocidade(Client, args)
{
    if (!pativado[Client])
    {
        pativado[Client] = true;
        CreateTimer(1.0, PuloVelocidade, Client, TIMER_REPEAT);
        PrintToChat(Client, CTAG, "PularVelocidadeAtivado", GREEN, YELLOW);
    } else {
        pativado[Client] = false;
        PrintToChat(Client, CTAG, "PularVelocidadeDesativado", GREEN, YELLOW);
    }
    return Plugin_Handled;
}

public Action:PuloVelocidade(Handle:timer, any:Client)
{
    if (pativado[Client])
    {
        new Float:vec[3];
        GetEntPropVector(Client, Prop_Data, "m_vecVelocity", vec);
        new velocidade = RoundToFloor(SquareRoot(Pow(vec[0],2.0)+Pow(vec[1],2.0)+Pow(vec[2],2.0))*0.06858);
        PrintHintText(Client, "Pulos executados: %i | Velocidade atual: %iKm/H", pulos[Client], velocidade);
        return Plugin_Continue;
    } else {
        return Plugin_Stop;
    }
}

public Action:OverlayTemporizador(Handle:timer, any:Client)
{
    if (matover[Client])
    {
        decl String:overlay[PLATFORM_MAX_PATH];
        GetConVarString(cvarOver, overlay, sizeof(overlay));
        ClientCommand(Client, "r_screenoverlay \"%s\"", overlay);
        return Plugin_Continue;
    } else {
        return Plugin_Stop;
    }
}

public Action:C_Scout(Client, args)
{
    new bool:bhopativado = GetConVarBool(cvarBAtivado);
    if (bhopativado)
    {
        new String:arma[20], String:nomearma[13];
        GetConVarString(cvarArma, nomearma, sizeof(nomearma));
        Format(arma, sizeof(arma), "weapon_%s", nomearma);
        new limite = GetConVarInt(cvarScoutlimite);
        if (scouts[Client] < limite || limite == 0)
        {
            GivePlayerItem(Client, arma);
            scouts[Client]++;
            PrintToChat(Client, CTAG, "Dada", GREEN, YELLOW, nomearma, limite);
        } else {
            PrintToChat(Client, CTAG, "LimiteScout", GREEN, YELLOW, limite, nomearma);
        }
    } else {
        PrintToChat(Client, CTAG, "Desativado", GREEN, YELLOW);
    }
    return Plugin_Handled;
}

public Action:C_Bhop(Client, args)
{
    new bool:bhopativado = GetConVarBool(cvarBAtivado);
    if (bhopativado)
    {
        BhopMenu(Client);
    } else {
        PrintToChat(Client, CTAG, "Desativado", GREEN, YELLOW);
    }
    return Plugin_Handled;
}

public BhopMenu(Client)
{
    new Handle:bmenu = CreateMenu(hbmenu);
    SetMenuTitle(bmenu, "[CSBrazucas.com] Bhop");
    AddMenuItem(bmenu, "Salvar", "Salva as cordenadas atuais");
    AddMenuItem(bmenu, "Teleportar", "Teleporta para as cordenadas salvas");
    AddMenuItem(bmenu, "Pulos e Velocidade", "Mostra a velocidade atual e a quantidade de pulos");
    AddMenuItem(bmenu, "Tempo", "Mostrar o tempo conectado ao servidor");
    AddMenuItem(bmenu, "Scout", "Pedir uma scout");
    AddMenuItem(bmenu, "Musica", "Parar a musica de vinda ao server");
    SetMenuExitButton(bmenu, true);
    SetMenuOptionFlags(bmenu, MENUFLAG_BUTTON_EXIT);
    DisplayMenu(bmenu, Client, MENU_TIME_FOREVER);
}

public hbmenu(Handle:menu, MenuAction:action, Client, selec)
{
    if (action == MenuAction_Select)
    {
        switch (selec)
        {
            case 0: SalvarCordenadas(Client);
            case 1: TeleportarCordenadas(Client);
            case 2: ClientCommand(Client, "sm_info");
            case 3: MostrarTempo(Client);
            case 4: ClientCommand(Client, "sm_scout");
            case 5: ClientCommand(Client, "play UI/buttonclick.wav");
        }
        BhopMenu(Client);
    } else if (action == MenuAction_End)
        CloseHandle(menu);
}

public Action:C_Salvar(Client, args)
{
    new bool:bhopativado = GetConVarBool(cvarBAtivado);
    if (bhopativado)
    {
        SalvarCordenadas(Client);
    } else {
        PrintToChat(Client, CTAG, "Desativado", GREEN, YELLOW);
    }
    return Plugin_Handled;
}

public Action:C_Tele(Client, args)
{
    new bool:bhopativado = GetConVarBool(cvarBAtivado);
    if (bhopativado)
    {
        TeleportarCordenadas(Client);
    } else {
        PrintToChat(Client, CTAG, "Desativado", GREEN, YELLOW);
    }
    return Plugin_Handled;
}

SalvarCordenadas(Client)
{
    new Float:vec[3];
    GetEntPropVector(Client, Prop_Data, "m_vecVelocity", vec);
    new velocidade = RoundToFloor(SquareRoot(Pow(vec[0],2.0)+Pow(vec[1],2.0)+Pow(vec[2],2.0))*0.06858);
    if (velocidade == 0 && GetEntDataEnt2(Client, FindSendPropOffs("CBasePlayer", "m_hGroundEntity")) != -1)
    {
        usado[Client] = true;
        GetClientAbsOrigin(Client, cord[Client]);
        PrintToChat(Client, CTAG, "Salvo", GREEN, YELLOW);
    } else if (GetEntDataEnt2(Client, FindSendPropOffs("CBasePlayer", "m_hGroundEntity")) == -1)
    {
        PrintToChat(Client, CTAG, "Chao", GREEN, YELLOW);
    } else if (velocidade != 0)
    {
        PrintToChat(Client, CTAG, "Velocidade", GREEN, YELLOW);
    }
}

TeleportarCordenadas(Client)
{
    if (usado[Client])
    {
        TeleportEntity(Client, cord[Client], NULL_VECTOR, NULL_VECTOR);
    } else {
        PrintToChat(Client, CTAG, "NaoSalvo", GREEN, YELLOW);
    }
}

public Action:C_VClip(Client, args)
{
    new MoveType:movetype = GetEntityMoveType(Client);
    if (movetype == MOVETYPE_NOCLIP)
    {
        SetEntityMoveType(Client, MOVETYPE_WALK);
        SetEntityRenderFx(Client, RENDERFX_NONE);
    } else {
        PrintToChat(Client, CTAG, "Caminhando", GREEN, YELLOW);
    }
    return Plugin_Handled;
}

public Action:C_NoClip(Client, args)
{
    new num = GetCmdArgs();
    if (num > 0)
    {
        new String:target_name[MAX_TARGET_LENGTH], String:yoo[32];
        new target_list[MAXPLAYERS], target_count;
        new bool:tn_is_ml;
        GetCmdArg(1, yoo, sizeof(yoo));
        if ((target_count = ProcessTargetString(
            yoo,
            Client,
            target_list,
            MAXPLAYERS,
            COMMAND_FILTER_ALIVE,
            target_name,
            sizeof(target_name),
            tn_is_ml)) <= 0)
        {
            ReplyToTargetError(Client, target_count);
            return Plugin_Handled;
        }
        for (new i = 0; i < target_count; i++)
        {
            SNoClip(Client, target_list[i]);
        }
    } else {
        SNoClip(Client, Client);
    }
    return Plugin_Handled;
}

SNoClip(Client, alvo)
{
    new MoveType:movetype = GetEntityMoveType(alvo);
    if (movetype != MOVETYPE_NOCLIP)
    {
        if (Client != alvo)
        {
            new String:nomeum[MAX_NAME_LENGTH], String:nomedois[MAX_NAME_LENGTH];
            GetClientName(Client, nomeum, sizeof(nomeum));
            GetClientName(alvo, nomedois, sizeof(nomedois));
            PrintToChat(alvo, CTAG, "RecebeuClip", GREEN, YELLOW, nomeum);
            PrintToChat(Client, CTAG, "DadoClip", GREEN, YELLOW, nomedois);
            PrintToChat(alvo, CTAG, "Dica", GREEN, YELLOW);
        } else {
            PrintToChat(Client, CTAG, "Proprio", GREEN, YELLOW);
        }
        SetEntityMoveType(alvo, MOVETYPE_NOCLIP);
        SetEntityRenderFx(alvo, RENDERFX_FADE_FAST);
    } else {
        SetEntityMoveType(alvo, MOVETYPE_WALK);
        SetEntityRenderFx(alvo, RENDERFX_NONE);
    }
}

MostrarTempo(Client)
{
    new total = RoundToFloor(GetClientTime(Client)/60.00);
    PrintCenterText(Client, "Voce esta conectado ao servidor por %i minutos (inteiros)", total);
}
*Improves:
- new bool (matover[MAXPLAYERS+1])
- Plugin Continue/Stop function, like i did with the tracer, etc.
- changing overlay bool at the 'OnPlayerConnected' (wich is similar to disconnected)

Sorry for bodering you, but is that all? Do you think i need to really call a 'killtimer' function? Sorry if i didnt get the "ingame,alive checks in the timer" thing... And how about the OnMapStart Download functions?

PS: it did not worked

Last edited by Shadow Of Death @ CSB; 09-10-2010 at 22:36.
Shadow Of Death @ CSB 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 20:42.


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