xmod shared natives
This commit is contained in:
parent
ffad9e7af4
commit
5bf3577d9c
|
@ -61,12 +61,6 @@ native get_statsnum();
|
|||
native get_user_stats2(index,stats[4]);
|
||||
native get_stats2(index,stats[4]);
|
||||
|
||||
/* Custom weapons support ( like: gasnades, lasers ) */
|
||||
native reg_custom_weapon( wpnname[],melee = 0,logname[]="" );
|
||||
native custom_weapon_dmg( weapon, att, vic, damage, hitplace );
|
||||
native custom_weapon_shot( weapon,index ); // weapon id , player id
|
||||
native get_custom_wpnname( weapon,szName[],len );
|
||||
|
||||
/*
|
||||
* Forwards
|
||||
*/
|
||||
|
@ -78,7 +72,46 @@ enum {
|
|||
CSF_DEATH,
|
||||
}
|
||||
|
||||
/* You must register client_* forwards using register_statsfwd native */
|
||||
native register_statsfwd( ftype )
|
||||
/************* Shared Natives Start ********************************/
|
||||
|
||||
/* Forward types */
|
||||
enum {
|
||||
XMF_DAMAGE = 0,
|
||||
XMF_DEATH,
|
||||
}
|
||||
|
||||
/* Use this function to register forwards */
|
||||
native register_statsfwd( ftype );
|
||||
|
||||
/* Function is called after player to player attacks ,
|
||||
* if players were damaged by teammate TA is set to 1 */
|
||||
forward client_damage(attacker,victim,damage,wpnindex,hitplace,TA);
|
||||
|
||||
/* Function is called after player death ,
|
||||
* if player was killed by teammate TK is set to 1 */
|
||||
forward client_death(killer,victim,wpnindex,hitplace,TK);
|
||||
|
||||
/* Custom Weapon Support */
|
||||
/* function will return index of new weapon */
|
||||
native custom_weapon_add( wpnname[],melee = 0,logname[]="" );
|
||||
/* Function will pass damage done by this custom weapon to stats module and other plugins */
|
||||
native custom_weapon_dmg( weapon, att, vic, damage, hitplace=0 );
|
||||
/* Function will pass info about custom weapon shot to stats module */
|
||||
native custom_weapon_shot( weapon,index ); // weapon id , player id
|
||||
|
||||
/* function will return 1 if true */
|
||||
native xmod_is_melee_wpn(wpnindex);
|
||||
|
||||
/* Returns weapon name. */
|
||||
native xmod_get_wpnname(wpnindex,name[],len);
|
||||
|
||||
/* Returns weapon logname. */
|
||||
native xmod_get_wpnlogname(wpnindex,name[],len);
|
||||
|
||||
/* Returns weapons array size */
|
||||
native xmod_get_maxweapons();
|
||||
|
||||
/* Returns stats array size */
|
||||
native xmod_get_stats_size();
|
||||
|
||||
/************* Shared Natives End ********************************/
|
||||
|
|
|
@ -290,9 +290,12 @@ static cell AMX_NATIVE_CALL register_cwpn(AMX *amx, cell *params){ // name,logna
|
|||
|
||||
int iLen;
|
||||
char *szName = MF_GetAmxString(amx, params[1], 0, &iLen);
|
||||
char *szLogName = MF_GetAmxString(amx, params[3], 0, &iLen);
|
||||
|
||||
strcpy(weaponData[i].name,szName);
|
||||
strcpy(weaponData[i].logname,szLogName);
|
||||
weaponData[i].ammoSlot = 1;
|
||||
weaponData[i].melee = params[2] ? true:false;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
@ -370,9 +373,9 @@ static cell AMX_NATIVE_CALL custom_wpn_shot(AMX *amx, cell *params){ // player,w
|
|||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_custom_wpnname(AMX *amx, cell *params){
|
||||
static cell AMX_NATIVE_CALL get_wpnname(AMX *amx, cell *params){
|
||||
int id = params[1];
|
||||
if (id<MAX_WEAPONS || id>=MAX_WEAPONS+MAX_CWEAPONS ){
|
||||
if (id<0 || id>=MAX_WEAPONS+MAX_CWEAPONS ){
|
||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||
MF_PrintSrvConsole("Weapon ID Is Not Valid!\n");
|
||||
return 0;
|
||||
|
@ -380,6 +383,28 @@ static cell AMX_NATIVE_CALL get_custom_wpnname(AMX *amx, cell *params){
|
|||
return MF_SetAmxString(amx,params[2],weaponData[id].name,params[3]);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_wpnlogname(AMX *amx, cell *params){
|
||||
int id = params[1];
|
||||
if (id<0 || id>=MAX_WEAPONS+MAX_CWEAPONS ){
|
||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||
MF_PrintSrvConsole("Weapon ID Is Not Valid!\n");
|
||||
return 0;
|
||||
}
|
||||
return MF_SetAmxString(amx,params[2],weaponData[id].logname,params[3]);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL is_melee(AMX *amx, cell *params){
|
||||
int id = params[1];
|
||||
if (id<0 || id>=MAX_WEAPONS+MAX_CWEAPONS ){
|
||||
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
|
||||
MF_PrintSrvConsole("Weapon ID Is Not Valid!\n");
|
||||
return 0;
|
||||
}
|
||||
if ( id = 29 )
|
||||
return 1;
|
||||
return weaponData[id].melee ? 1:0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward
|
||||
int iFunctionIndex;
|
||||
switch( params[1] ){
|
||||
|
@ -404,6 +429,14 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward
|
|||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_maxweapons(AMX *amx, cell *params){
|
||||
return MAX_WEAPONS+MAX_CWEAPONS;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_stats_size(AMX *amx, cell *params){
|
||||
return 8;
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO stats_Natives[] = {
|
||||
{ "get_stats", get_stats},
|
||||
{ "get_stats2", get_stats2},
|
||||
|
@ -419,10 +452,15 @@ AMX_NATIVE_INFO stats_Natives[] = {
|
|||
{ "reset_user_wstats", reset_user_wstats },
|
||||
|
||||
// Custom Weapon Support
|
||||
{ "reg_custom_weapon", register_cwpn },
|
||||
{ "custom_weapon_add", register_cwpn },
|
||||
{ "custom_weapon_dmg", custom_wpn_dmg },
|
||||
{ "custom_weapon_shot", custom_wpn_shot },
|
||||
{ "get_custom_wpnname", get_custom_wpnname },
|
||||
|
||||
{ "xmod_get_wpnname", get_wpnname },
|
||||
{ "xmod_get_wpnlogname", get_wpnlogname },
|
||||
{ "xmod_is_melee_wpn", is_melee },
|
||||
{ "xmod_get_maxweapons", get_maxweapons },
|
||||
{ "xmod_get_stats_size", get_stats_size },
|
||||
|
||||
{ "register_statsfwd",register_forward },
|
||||
|
||||
|
|
|
@ -19,7 +19,9 @@ extern AMX_NATIVE_INFO stats_Natives[];
|
|||
|
||||
struct weaponsVault {
|
||||
char* name;
|
||||
char* logname;
|
||||
short int ammoSlot;
|
||||
bool melee;
|
||||
};
|
||||
|
||||
extern bool rankBots;
|
||||
|
|
|
@ -46,6 +46,7 @@ void Client_WeaponList(void* mValue){
|
|||
weaponData[iId].name = wpnPrefix + 7;
|
||||
if ( strcmp( weaponData[iId].name, "hegrenade" ) == 0 )
|
||||
weaponData[iId].name += 2;
|
||||
weaponData[iId].logname = weaponData[iId].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,13 +213,18 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward
|
|||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_maxweapons(AMX *amx, cell *params){
|
||||
return DODMAX_WEAPONS;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_stats_size(AMX *amx, cell *params){
|
||||
return 9;
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO base_Natives[] = {
|
||||
|
||||
{ "dod_get_wpnname", get_weapon_name },
|
||||
{ "dod_get_wpnlogname", get_weapon_logname },
|
||||
{ "dod_wpnlog_to_name", wpnlog_to_name },
|
||||
{ "dod_wpnlog_to_id", wpnlog_to_id },
|
||||
{ "dod_is_melee", is_melee },
|
||||
|
||||
{ "dod_get_team_score", get_team_score },
|
||||
{ "dod_get_user_score", get_user_score },
|
||||
|
@ -230,6 +235,12 @@ AMX_NATIVE_INFO base_Natives[] = {
|
|||
{ "dod_user_kill", user_kill },
|
||||
{ "dod_get_pronestate", get_user_pronestate },
|
||||
|
||||
{ "xmod_get_wpnname", get_weapon_name },
|
||||
{ "xmod_get_wpnlogname", get_weapon_logname },
|
||||
{ "xmod_is_melee_wpn", is_melee },
|
||||
{ "xmod_get_maxweapons", get_maxweapons },
|
||||
{ "xmod_get_stats_size", get_stats_size },
|
||||
|
||||
{"register_statsfwd",register_forward },
|
||||
|
||||
///*******************
|
||||
|
|
|
@ -439,7 +439,7 @@ AMX_NATIVE_INFO stats_Natives[] = {
|
|||
{ "reset_user_wstats", reset_user_wstats },
|
||||
|
||||
// Custom Weapon Support
|
||||
{ "reg_custom_weapon", register_cwpn }, // name,melee,logname
|
||||
{ "custom_weapon_add", register_cwpn }, // name,melee,logname
|
||||
{ "custom_weapon_dmg", cwpn_dmg },
|
||||
{ "custom_weapon_shot", cwpn_shot },
|
||||
|
||||
|
|
|
@ -267,6 +267,8 @@ static cell AMX_NATIVE_CALL TFC_GetWeaponBAmmo(AMX *amx, cell *params) {
|
|||
case TFC_WPN_GASGRENADE:
|
||||
case TFC_WPN_EMPGRENADE:
|
||||
return *( (int*)pPlayer->pEdict->pvPrivateData + PD_AMMO_NADE2);
|
||||
|
||||
|
||||
break;
|
||||
default :
|
||||
return 0;
|
||||
|
@ -415,6 +417,14 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward
|
|||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_maxweapons(AMX *amx, cell *params){
|
||||
return TFCMAX_WEAPONS;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_stats_size(AMX *amx, cell *params){
|
||||
return 8;
|
||||
}
|
||||
|
||||
// Native list.
|
||||
AMX_NATIVE_INFO base_Natives[] = {
|
||||
{"tfc_setmodel", TFC_SetModel},
|
||||
|
@ -423,10 +433,13 @@ AMX_NATIVE_INFO base_Natives[] = {
|
|||
{"tfc_getbammo", TFC_GetBAmmo},
|
||||
{"tfc_getweaponbammo", TFC_GetWeaponBAmmo},
|
||||
{"tfc_setweaponbammo", TFC_SetWeaponBAmmo},
|
||||
{"tfc_getwpnname", TFC_GetWpnName},
|
||||
{"tfc_getwpnlogname", TFC_GetWpnLogName},
|
||||
|
||||
{"tfc_ismelee", TFC_IsMelee},
|
||||
{"xmod_get_wpnname", TFC_GetWpnName},
|
||||
{"xmod_get_wpnlogname", TFC_GetWpnLogName},
|
||||
{"xmod_is_melee_wpn", TFC_IsMelee},
|
||||
{"xmod_get_maxweapons", get_maxweapons},
|
||||
{"xmod_get_stats_size", get_stats_size},
|
||||
|
||||
{"tfc_userkill" , TFC_UserKill},
|
||||
|
||||
{"tfc_setpddata", TFC_SetPDdata },
|
||||
|
|
|
@ -363,7 +363,7 @@ AMX_NATIVE_INFO stats_Natives[] = {
|
|||
{ "reset_user_wstats", reset_user_wstats },
|
||||
|
||||
// Custom Weapon Support
|
||||
{ "reg_custom_weapon", register_cwpn },
|
||||
{ "custom_weapon_add", register_cwpn },
|
||||
{ "custom_weapon_dmg", cwpn_dmg },
|
||||
{ "custom_weapon_shot", cwpn_shot },
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ struct CPlayer {
|
|||
//
|
||||
int killingSpree;
|
||||
int is_specialist;
|
||||
int killFlags;
|
||||
int lastFrag; // oblicz ostatni frag, sprawdza czy poprawna jest detekcja broni i bonusow
|
||||
float lastKill; // kiedy ostatni , dla double kill
|
||||
//
|
||||
|
|
|
@ -186,6 +186,19 @@ static cell AMX_NATIVE_CALL get_lastFrag(AMX *amx, cell *params){
|
|||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_killflags(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 ){
|
||||
return pPlayer->killFlags;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL give_weapon(AMX *amx, cell *params){ // index,weapon,clips,extra
|
||||
int id = params[1];
|
||||
if ( id<1 || id>gpGlobals->maxClients ){
|
||||
|
@ -361,12 +374,26 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params){ // forward
|
|||
return 1;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_maxweapons(AMX *amx, cell *params){
|
||||
return TSMAX_WEAPONS;
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL get_stats_size(AMX *amx, cell *params){
|
||||
return 8;
|
||||
}
|
||||
|
||||
|
||||
AMX_NATIVE_INFO base_Natives[] = {
|
||||
{ "ts_getwpnname", get_weapon_name },
|
||||
{ "ts_getwpnlogname", get_weapon_logname },
|
||||
|
||||
{ "xmod_get_wpnname", get_weapon_name },
|
||||
{ "xmod_get_wpnlogname", get_weapon_logname },
|
||||
{ "xmod_is_melee_wpn", is_melee },
|
||||
{ "xmod_get_maxweapons", get_maxweapons },
|
||||
{ "xmod_get_stats_size", get_stats_size },
|
||||
|
||||
{ "ts_wpnlogtoname", wpnlog_to_name },
|
||||
{ "ts_wpnlogtoid", wpnlog_to_id },
|
||||
{ "ts_ismelee", is_melee },
|
||||
|
||||
{ "ts_getuserwpn", get_user_weapon },
|
||||
{ "ts_getusercash", get_user_cash },
|
||||
{ "ts_getuserspace", get_user_space },
|
||||
|
@ -374,6 +401,7 @@ AMX_NATIVE_INFO base_Natives[] = {
|
|||
{ "ts_getuseritems",get_user_items },
|
||||
{ "ts_getkillingstreak",get_killingStreak },
|
||||
{ "ts_getuserlastfrag",get_lastFrag },
|
||||
{ "ts_getuserkillflags",get_killflags },
|
||||
|
||||
{ "ts_giveweapon",give_weapon },
|
||||
{ "ts_createpwup",create_pwup },
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* TFCX
|
||||
* TSX
|
||||
* Copyright (c) 2004 Lukasz Wlasinski
|
||||
*
|
||||
*
|
||||
|
@ -363,7 +363,7 @@ AMX_NATIVE_INFO stats_Natives[] = {
|
|||
{ "reset_user_wstats", reset_user_wstats },
|
||||
|
||||
// Custom Weapon Support
|
||||
{ "reg_custom_weapon", register_cwpn },
|
||||
{ "custom_weapon_add", register_cwpn },
|
||||
{ "custom_weapon_dmg", cwpn_dmg },
|
||||
{ "custom_weapon_shot", cwpn_shot },
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* TFCX
|
||||
* TSX
|
||||
* Copyright (c) 2004 Lukasz Wlasinski
|
||||
*
|
||||
*
|
||||
|
|
|
@ -41,6 +41,7 @@ void Client_ResetHUD_End(void* mValue){
|
|||
mPlayer->items = 0;
|
||||
mPlayer->is_specialist = 0;
|
||||
mPlayer->killingSpree = 0;
|
||||
mPlayer->killFlags = 0;
|
||||
mPlayer->frags = (int)mPlayer->pEdict->v.frags;
|
||||
/*
|
||||
fix dla user_kill() z addfrag
|
||||
|
@ -216,8 +217,9 @@ void Client_TSHealth_End(void* mValue){
|
|||
}
|
||||
}
|
||||
|
||||
pAttacker->killFlags = killFlags;
|
||||
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TA);
|
||||
g_death_info.exec( pAttacker->index, mPlayer->index, weapon, aim, killFlags, TA );
|
||||
g_death_info.exec( pAttacker->index, mPlayer->index, weapon, aim, TA );
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user