PDA

View Full Version : set_speak() in fakemeta


MPNumB
04-08-2008, 07:58
How to make g[s]et_speak() in fakemeta?

Exolent[jNr]
04-08-2008, 08:40
FM_Voice_SetClientListening

MPNumB
04-08-2008, 09:48
Thats forward, so how shold I change it? And what are parametors of that forward?

Exolent[jNr]
04-08-2008, 10:15
FM_Voice_SetClientListening, // bool ) (iReceiver, iSender, bool:bListen)


#include <amxmodx>
#include <fakemeta>

#define SPEAK_MUTED 0
#define SPEAK_NORMAL 1
#define SPEAK_ALL 2
#define SPEAK_LISTENALL 3
#define SPEAK_TEAM 4

new g_iSpeakFlags[33];

#define fm_set_speak(%1, %2) g_iSpeakFlags[%1] = %2
#define fm_get_speak(%1) g_iSpeakFlags[%1]

public plugin_init()
{
register_forward(FM_Voice_SetClientListening, "fwd_FM_Voice_SetClientListening");
}

public client_connect(id)
{
g_iSpeakFlags[id] = SPEAK_NORMAL;
}

public fwd_FM_Voice_SetClientListening(receiver, sender, bool:bListen)
{
// this is sometimes called for players that aren't connected
if(!is_user_connected(receiver) || !is_user_connected(sender) || g_iSpeakFlags[sender] == SPEAK_NORMAL && g_iSpeakFlags[receiver] != SPEAK_LISTENALL)
{
return FMRES_IGNORED;
}

new iSpeakType = 0;
if(g_iSpeakFlags[sender] == SPEAK_ALL
|| g_iSpeakFlags[receiver] == SPEAK_LISTENALL
|| g_iSpeakFlags[sender] == SPEAK_TEAM && get_pdata_int(sender, 114) == get_pdata_int(receiver, 114))
{
iSpeakType = 1;
}

engfunc(EngFunc_SetClientListening, receiver, sender, iSpeakType);
return FMRES_SUPERCEDE;
}

Note:
SPEAK_TEAM is not a default flag.
It is something I thought of myself so teammates can talk to each other as if sv_alltalk is 1.

Stocks:
fm_set_speak(index, iSpeakFlag) - sets client's speak mode
fm_get_speak(index) - returns client's current speak mode

MPNumB
04-08-2008, 10:53
Two more questions.

get_pdata_int(player, 114) is something like get_user_team(player) if I understood the code currectly.

So it uses less cpu than get_user_team()? And will it work for linux the same as for win32?

P.S. You shold write this in http://forums.alliedmods.net/forumdisplay.php?f=83

Exolent[jNr]
04-08-2008, 11:06
get_pdata_int(index, 114) is the fakemeta equivalent of cs_get_user_team(index) of the cstrike module

EDIT:P.S. You shold write this in http://forums.alliedmods.net/forumdisplay.php?f=83

Ok.
http://forums.alliedmods.net/showthread.php?t=69654

MPNumB
04-08-2008, 20:56
so why get_user_team() is worser? I foth it detects 3 types:
cs example:
CT
T
OTHER

or i'm wrong?

YamiKaitou
04-08-2008, 21:08
get_user_team sometimes will return a false result in CS

MPNumB
04-08-2008, 21:15
Than how meny duffrent values can get_pdata_int(player, 114) return?

CT
T
SPEC
UN

???

Exolent[jNr]
04-08-2008, 22:26
It returns the same values.