From 27f5e72afea48e725acf734f782b37971d2cb8de Mon Sep 17 00:00:00 2001 From: Lukasz Wlasinksi Date: Fri, 6 Aug 2004 13:58:20 +0000 Subject: [PATCH] small changes in natives --- dlls/dod2/dodx/NBase.cpp | 43 ++++++++++++++++++++++++++++++++++++++++ dlls/tfc/tfcx/NBase.cpp | 5 +++++ dlls/ts/tsx/NBase.cpp | 26 ++++++++++++++++++++++-- 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/dlls/dod2/dodx/NBase.cpp b/dlls/dod2/dodx/NBase.cpp index 0f75435f..1e66c3d1 100755 --- a/dlls/dod2/dodx/NBase.cpp +++ b/dlls/dod2/dodx/NBase.cpp @@ -336,6 +336,42 @@ static cell AMX_NATIVE_CALL is_custom(AMX *amx, cell *params){ return 1; } +static cell AMX_NATIVE_CALL dod_get_user_team(AMX *amx, cell *params){ // player,wid + int index = params[2]; + if (index<1||index>gpGlobals->maxClients){ + MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + return 0; + } + + CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); + return pPlayer->pEdict->v.team; + +} + +static cell AMX_NATIVE_CALL get_user_team(AMX *amx, cell *params){ // player,wid + int index = params[2]; + if (index<1||index>gpGlobals->maxClients){ + MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + return 0; + } + + CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); + int iTeam = pPlayer->pEdict->v.team; + if ( params[3] ){ + char *szTeam = ""; + switch(iTeam){ + case 1: + szTeam = "Allies"; + break; + case 2: + szTeam = "Axis"; + break; + } + MF_SetAmxString(amx,params[2],szTeam,params[3]); + } + return iTeam; +} + AMX_NATIVE_INFO base_Natives[] = { { "dod_wpnlog_to_name", wpnlog_to_name }, @@ -364,6 +400,13 @@ AMX_NATIVE_INFO base_Natives[] = { { "custom_weapon_dmg", cwpn_dmg }, { "custom_weapon_shot", cwpn_shot }, + //**************************************** + + { "get_user_team", get_user_team }, + { "get_weaponname", get_weapon_name }, + { "get_user_weapon", get_user_weapon }, + { "dod_get_user_team", dod_get_user_team }, + ///******************* { NULL, NULL } }; \ No newline at end of file diff --git a/dlls/tfc/tfcx/NBase.cpp b/dlls/tfc/tfcx/NBase.cpp index b6bb7279..e10995c4 100755 --- a/dlls/tfc/tfcx/NBase.cpp +++ b/dlls/tfc/tfcx/NBase.cpp @@ -454,6 +454,11 @@ AMX_NATIVE_INFO base_Natives[] = { {"tfc_setpddata", TFC_SetPDdata }, {"register_statsfwd",register_forward }, + + //***************************************** + + {"get_weaponname", TFC_GetWpnName}, + //******************* 19 :) {NULL, NULL} }; diff --git a/dlls/ts/tsx/NBase.cpp b/dlls/ts/tsx/NBase.cpp index ab63e760..e3ebba2c 100755 --- a/dlls/ts/tsx/NBase.cpp +++ b/dlls/ts/tsx/NBase.cpp @@ -84,7 +84,7 @@ static cell AMX_NATIVE_CALL is_melee(AMX *amx, cell *params){ return 0; } -static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params){ +static cell AMX_NATIVE_CALL ts_get_user_weapon(AMX *amx, cell *params){ int id = params[1]; if ( id<1 || id>gpGlobals->maxClients ){ MF_RaiseAmxError(amx,AMX_ERR_NATIVE); @@ -106,6 +106,24 @@ static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params){ return 0; } +static cell AMX_NATIVE_CALL get_user_weapon(AMX *amx, cell *params){ + int id = params[1]; + if ( id<1 || id>gpGlobals->maxClients ){ + MF_RaiseAmxError(amx,AMX_ERR_NATIVE); + return 0; + } + CPlayer *pPlayer = GET_PLAYER_POINTER_I(id); + if ( pPlayer->ingame ){ + int wpn = pPlayer->current; + cell *cpTemp = MF_GetAmxAddr(amx,params[2]); + *cpTemp = pPlayer->weapons[wpn].clip; + cpTemp = MF_GetAmxAddr(amx,params[3]); + *cpTemp = pPlayer->weapons[wpn].ammo; + return wpn; + } + return 0; +} + static cell AMX_NATIVE_CALL get_user_cash(AMX *amx, cell *params){ int id = params[1]; if ( id<1 || id>gpGlobals->maxClients ){ @@ -402,7 +420,7 @@ AMX_NATIVE_INFO base_Natives[] = { { "ts_wpnlogtoname", wpnlog_to_name }, { "ts_wpnlogtoid", wpnlog_to_id }, - { "ts_getuserwpn", get_user_weapon }, + { "ts_getuserwpn", ts_get_user_weapon }, { "ts_getusercash", get_user_cash }, { "ts_getuserspace", get_user_space }, { "ts_getuserpwup",get_user_pwup }, @@ -419,6 +437,10 @@ AMX_NATIVE_INFO base_Natives[] = { { "register_statsfwd",register_forward }, + //**************************************** + { "get_weaponname", get_weapon_name }, + { "get_user_weapon", get_user_weapon }, + //"*******************" { NULL, NULL } }; \ No newline at end of file