Added ns_get_user_team for a replacement for get_user_team.

This commit is contained in:
Steve Dudenhoeffer 2007-08-03 02:57:59 +00:00
parent 7038305812
commit e254ef6b15
2 changed files with 78 additions and 0 deletions

View File

@ -188,6 +188,72 @@ static cell AMX_NATIVE_CALL ns_giveitem(AMX *amx, cell *params)
return 1; return 1;
} }
static cell AMX_NATIVE_CALL ns_get_user_team(AMX* amx, cell* params)
{
CreatePlayerPointer(amx,params[1]);
if (!player->IsConnected())
{
return 0;
}
int team = player->GetPev()->team;
if (team > 4 || team < 0)
{
MF_SetAmxString(amx, params[2], "undefinedteam", params[3]);
return 0;
}
switch (team)
{
case 0:
{
// iuser1 means readyroom (I think!)
if (player->GetPev()->iuser1 == 0)
{
MF_SetAmxString(amx, params[2], "undefinedteam", params[3]);
return 0;
}
MF_SetAmxString(amx, params[2], "spectatorteam", params[3]);
return 0;
}
case 1:
{
MF_SetAmxString(amx, params[2], "marine1team", params[3]);
return 1;
}
case 2:
{
MF_SetAmxString(amx, params[2], "alien1team", params[3]);
return 2;
}
case 3:
{
MF_SetAmxString(amx, params[2], "marine2team", params[3]);
return 3;
}
case 4:
{
MF_SetAmxString(amx, params[2], "alien2team", params[3]);
return 4;
}
default:
{
break;
}
}
MF_SetAmxString(amx, params[2], "spectatorteam", params[3]);
return 0;
}
AMX_NATIVE_INFO player_natives[] = { AMX_NATIVE_INFO player_natives[] = {
@ -212,6 +278,8 @@ AMX_NATIVE_INFO player_natives[] = {
{ "ns_set_fov", ns_set_fov }, { "ns_set_fov", ns_set_fov },
{ "ns_give_item", ns_giveitem }, { "ns_give_item", ns_giveitem },
{ "ns_get_user_team", ns_get_user_team },
{ NULL, NULL } { NULL, NULL }

View File

@ -64,6 +64,16 @@ native ns_is_combat();
*/ */
native NSGameplay:ns_get_gameplay(); native NSGameplay:ns_get_gameplay();
/**
* Exact syntax as get_user_team, but should be more accurate.
*
* @param id Player id.
* @param buff Buffer to store team name in.
* @param len Buffer length.
* @return The pev_team setting for the player.
*/
native ns_get_user_team(id, buff[], len);
/** /**
* Send an NS-style popup message. * Send an NS-style popup message.
* *