Junior Member
|
09-10-2010
, 22:27
Re: Player spawn refuses to work (and MapStart)
|
#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.
|
|