xmod shared natives

This commit is contained in:
Lukasz Wlasinksi
2004-08-05 01:02:39 +00:00
parent ffad9e7af4
commit 5bf3577d9c
13 changed files with 159 additions and 30 deletions

View File

@ -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 )
forward client_damage( attacker,victim,damage,wpnindex,hitplace,TA );
forward client_death( killer,victim,wpnindex,hitplace,TK );
/************* 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 ********************************/

View File

@ -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,12 +452,17 @@ 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 },
{"register_statsfwd",register_forward },
{ "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 },
///*******************
{ NULL, NULL }

View File

@ -19,7 +19,9 @@ extern AMX_NATIVE_INFO stats_Natives[];
struct weaponsVault {
char* name;
char* logname;
short int ammoSlot;
bool melee;
};
extern bool rankBots;

View File

@ -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;
}
}
}