Hi.
I've never worked with hamsandwich module before. Basically I'm making a plugin that would block Ts from clicking any button if IsFreeRun is "true", however, CTs would be still able to use them (no matter the IsFreeRun value).
The code is mainly taken from another plugin - Use Button Once.
PHP Code:
public plugin_init() {
// ...code...
if( engfunc(EngFunc_FindEntityByString,-1 ,"classname", "func_button"))
RegisterHam(Ham_Use, "func_button", "fwButtonUsed");
if(engfunc(EngFunc_FindEntityByString,-1 ,"classname","func_rot_button"))
RegisterHam(Ham_Use, "func_rot_button", "fwButtonUsed");
if(engfunc(EngFunc_FindEntityByString,-1 ,"classname", "button_target"))
RegisterHam(Ham_Use, "button_target", "fwButtonUsed");
}
//The function.. I know it's not the best way to use IFs
public fwButtonUsed(idcaller) {
if(IsFreeRun == true && get_user_team(idcaller) == 1) {
return HAM_SUPERCEDE;
}
if(IsFreeRun == true && get_user_team(idcaller) == 2) {
return FMRES_IGNORED;
}
return PLUGIN_HANDLED;
}
Not the full code (obviously), only the part that is not working, plugin completes fine - no errors. However, that button clicking thing is not working. Either no one can click them or buttons are usable no matter the IsFreeRun value.
Currently I'm not really interested in any optimizations (if any is possible), I just need to get the code to work.