Hi everybody,
sorry for my english but i'm french, thx to google for translation, my english is really rusty. :-)
I try to modifying this plugin for DoD:S without ToggleEffects but this doesn't work. :-)
All the mdl files for the hat will download to the right place and are in the good place to the server and fast_download (sv_downloadurl).
Cvar sm_christmas_hat_enable "1".
There is no error when compiling smx.
There is no error in the DoD: S console while playing the game.
There is no error in the sourcemod logs.
There is no error in the server logs (logs from the dod directory).
The comment sentences that I placed in the script are all launched so everything is going well with the script.
But we don't see the hats.
If you want to test the server :
steam://connect/82.65.74.77:27015
This is the .sp for test :
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#undef REQUIRE_PLUGIN
#define VERSION "1.3"
new g_Hat[MAXPLAYERS+1];
new Handle:g_hLookupAttachment = INVALID_HANDLE;
new Handle:CvarEnable;
public Plugin:myinfo =
{
name = "Christmas Hat DoD:S",
author = "Xilver266 Steam: donchopo modif Micmacx",
description = "Put a Christmas hat to players at spawn",
version = VERSION,
url = "servers-cfg.foroactivo.com"
};
public OnPluginStart()
{
AutoExecConfig(true, "christmas_hat");
HookEvent("player_spawn", PlayerSpawn);
HookEvent("player_death", PlayerDeath);
CreateConVar("sm_christmas_hat_version", VERSION, "Christmas Hat", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
new Handle:hGameConf = LoadGameConfigFile("hats.gamedata");
StartPrepSDKCall(SDKCall_Entity);
PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "LookupAttachment");
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
g_hLookupAttachment = EndPrepSDKCall();
CvarEnable = CreateConVar("sm_christmas_hat_enable", "1", "Enable Christmas hats. 0 -No | 1 -Yes", _, true, 0.0, true, 1.0);
}
public OnMapStart()
{
AddFileToDownloadsTable("materials/models/santahat/furballs.vmt");
AddFileToDownloadsTable("materials/models/santahat/santahat.vmt");
AddFileToDownloadsTable("materials/models/santahat/santahat.vtf");
AddFileToDownloadsTable("models/santahat/santahat.mdl");
AddFileToDownloadsTable("models/santahat/santahat.phy");
AddFileToDownloadsTable("models/santahat/santahat.vvd");
AddFileToDownloadsTable("models/santahat/santahat.sw.vtx");
AddFileToDownloadsTable("models/santahat/santahat.dx80.vtx");
AddFileToDownloadsTable("models/santahat/santahat.dx90.vtx");
PrecacheModel("models/santahat/santahat.mdl");
}
public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if(!IsClientInGame(client) || !IsPlayerAlive(client))
return Plugin_Continue;
RemoveHat(client);
PrintToChatAll("Lancement PlayerSpawn");
CreateTimer(0.0, TimerCreateHats, client);
return Plugin_Continue;
}
public Action:TimerCreateHats(Handle:timer, any:client)
{
PrintToChatAll("Lancement TimerCreateHats");
if (GetConVarBool(CvarEnable))
CreateHat(client);
return Plugin_Stop;
}
CreateHat(client)
{
PrintToChatAll("Lancement CreateHat donc CvarEnable ok")
if(!LookupAttachment(client, "forward"))
return;
if(GetClientTeam(client) == 1)
return;
new Float:or[3];
new Float:ang[3];
new Float:fForward[3];
new Float:fRight[3];
new Float:fUp[3];
GetClientAbsOrigin(client,or);
GetClientAbsAngles(client,ang);
ang[0] += 0.0;
ang[1] += 0.0;
ang[2] += 0.0;
new Float:fOffset[3];
fOffset[0] = 0.0;
fOffset[1] = -1.0;
fOffset[2] = 6.0;
GetAngleVectors(ang, fForward, fRight, fUp);
or[0] += fRight[0]*fOffset[0]+fForward[0]*fOffset[1]+fUp[0]*fOffset[2];
or[1] += fRight[1]*fOffset[0]+fForward[1]*fOffset[1]+fUp[1]*fOffset[2];
or[2] += fRight[2]*fOffset[0]+fForward[2]*fOffset[1]+fUp[2]*fOffset[2];
new ent = CreateEntityByName("prop_dynamic_override");
DispatchKeyValue(ent, "model", "models/santahat/santahat.mdl");
DispatchKeyValue(ent, "spawnflags", "4");
SetEntProp(ent, Prop_Data, "m_CollisionGroup", 2);
SetEntPropEnt(ent, Prop_Send, "m_hOwnerEntity", client);
DispatchSpawn(ent);
AcceptEntityInput(ent, "TurnOn", ent, ent, 0);
g_Hat[client] = ent;
SDKHook(ent, SDKHook_SetTransmit, ShouldHide);
TeleportEntity(ent, or, ang, NULL_VECTOR);
SetVariantString("!activator");
AcceptEntityInput(ent, "SetParent", client, ent, 0);
SetVariantString("forward");
AcceptEntityInput(ent, "SetParentAttachmentMaintainOffset", ent, ent, 0);
}
public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
RemoveHat(client);
}
public OnClientDisconnect(client)
{
RemoveHat(client);
}
public Action:ShouldHide(ent, client)
{
if(ent == g_Hat[client])
return Plugin_Handled;
if(IsClientInGame(client))
if(GetEntProp(client, Prop_Send, "m_iObserverMode") == 4 && GetEntPropEnt(client, Prop_Send, "m_hObserverTarget")>=0)
if(ent == g_Hat[GetEntPropEnt(client, Prop_Send, "m_hObserverTarget")])
return Plugin_Handled;
return Plugin_Continue;
}
stock LookupAttachment(client, String:point[])
{
if(g_hLookupAttachment==INVALID_HANDLE) return 0;
if( client<=0 || !IsClientInGame(client) ) return 0;
return SDKCall(g_hLookupAttachment, client, point);
}
public RemoveHat(client)
{
PrintToChatAll("Lancement RemoveHat");
if (g_Hat[client] != 0 && IsValidEdict(g_Hat[client]))
{
AcceptEntityInput(g_Hat[client], "Kill");
SDKUnhook(g_Hat[client], SDKHook_SetTransmit, ShouldHide);
g_Hat[client] = 0;
}
}
And i modifying : hats.gamedata.txt
I tested with "#default" like the original script, I also tested with "dod" but that doesn't change anything.
PHP Code:
"Games"
{
"#default"
{
"Signatures"
{
"LookupAttachment"
{
"library" "server"
"linux" "@_ZN14CBaseAnimating16LookupAttachmentEPKc"
"windows" "\x56\x8B\xF1\x80\xBE\x2A\x2A\x2A\x2A\x00\x75\x2A\x83\xBE\x2A\x2A\x2A\x2A\x00\x75\x2A\xE8\x2A\x2A\x2A\x2A\x85\xC0\x74\x2A\x8B\xCE\xE8\x2A\x2A\x2A\x2A\x8B\xB6\x2A\x2A\x2A\x2A\x85\xF6\x74\x2A\x83\x3E\x00\x75\x2A\x33\xC0\x5E\xC2\x04\x00\x8B\x44\x24\x08\x50\x56\xE8\x2A\x2A\x2A\x2A\x83\xC4\x08\x83\xC0\x01\x5E\xC2\x04\x00"
}
}
}
}
If anyone can help me that would be super nice.
Thank you in advance and see you soon.
Edit : My bad. I had not read all the posts and I see that this code is not working correctly. I'll try to take this code and modify it:
https://forums.alliedmods.net/showpo...71&postcount=3
Besides, why is this plugin that doesn't work still in the plugins? Plugin Search
+++. :-) :-) :-)