Raised This Month: $ Target: $400
 0% 

modify this plugin to be able to save lives in my DeathRun :)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ASUS_BG
Junior Member
Join Date: Jun 2010
Old 01-16-2011 , 14:11   modify this plugin to be able to save lives in my DeathRun :)
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <zombieplague>

/*START - From colorchat.inc by Numb */
enum Color {
    
NORMAL 1,
    
GREEN,
    
TEAM_COLOR,
    
GREY,
    
RED,
    
BLUE,
}

new 
TeamName[][] = {
    
"",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}
/*END - From colorchat.inc by Numb */

new data_vault,
cvar_data_save_typecvar_show_hpcvar_give_ammo_publiccvar_ammo_limit
public plugin_init() {
    
register_plugin("[ZP] Save-ammo by GM""1.5""GM")
    
register_cvar("Save-ammo_version","1.4",FCVAR_SERVER FCVAR_SPONLY)
    
    
register_clcmd("say","hook_say")
    
register_clcmd("say_team","hook_say")
    
    
register_event("Damage","event_damage","b","2!0","3=0","4!0"
    
    
cvar_data_save_type register_cvar("Save-ammo_data_save_type","1")
    
    
cvar_show_hp register_cvar("Save-ammo_show_hp","0")
    
    
cvar_give_ammo_public register_cvar("Save-ammo_public","1")
    
    
cvar_ammo_limit register_cvar("Save-ammo_limit","0")
    
    
data_vault nvault_open("Save-ammo")
}

public 
hook_say(id)
{
    new 
args[129], arg_cmd[6],arg_name[32],arg_ap[10]
    
read_args(args,128)
    
remove_quotes(args)
    
parse(argsarg_cmd,5arg_name,31arg_ap,9)
    
    if(
equali(arg_cmd,"/give"))
    {
        new 
name[32],target_name[32],targetnum_ap str_to_num(arg_ap)
        
get_user_name(id,name,31)
        
target cmd_target(id,arg_name,0)
        
get_user_name(target,target_name,31)
        
        if(!
target)
        {
            
ColorChat(id,GREEN,"[ZP]^x01 can't find player with that name ^x04%s^x01 .",arg_name)
            return
        }
        
        if(
equali(name,arg_name))
        {
            
ColorChat(id,GREEN,"[ZP]^x01 you can't give yourself.")
            return
        }
        
        if(
zp_get_user_ammo_packs(id) < num_ap)
        {
            
ColorChat(id,GREEN,"[ZP]^x01 you don't have ammo packs to give.")
            return
        }
        
        if(
num_ap <= 0)
        {
            
ColorChat(id,GREEN,"[ZP]^x01 you can only give the ammo pack from 1 to 10000.")
            return
        }
        
        
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) - num_ap)
        
zp_set_user_ammo_packs(targetzp_get_user_ammo_packs(target) + num_ap)
        
        
ColorChat(id,GREEN,"[ZP]^x01 you gave  ^x04%s^x01 ammo packs to ^x04%s^x01.",arg_ap,target_name)
        
ColorChat(target,GREEN,"[ZP] %s^x01 you received ^x04%s^x01 ammo packs.",name,arg_ap)
        
        if(
get_pcvar_num(cvar_give_ammo_public)) ColorChat(0,GREEN,"[ZP] %s^x01 gave ^x04%s^x01 ammo packs to ^x04%s^x01.",name,arg_ap,target_name)
    }
    
    if(
equali(arg_cmd,"/ap")) ColorChat(id,GREEN,"[ZP]^x01 you have  ^x04%i^x01 ammo packs.",zp_get_user_ammo_packs(id))
}

public 
event_damage(id)
{
    new 
killer,hp
    killer 
get_user_attacker(id)
    
hp get_user_health(id)
    
    if(!
is_user_connected(killer) || !is_user_connected(id)) return
    
    if(
hp 0)
    {
        switch(
get_pcvar_num(cvar_show_hp))
        {
            case 
1: if(zp_get_user_zombie(id)) client_print(killer,print_center,"HP: %i",hp)
            case 
2: if(zp_get_user_nemesis(id)) client_print(killer,print_center,"HP: %i",hp)
            case 
3: if(zp_get_user_zombie(id) || zp_get_user_nemesis(id)) client_print(killer,print_center,"HP: %i",hp)
        }
    } else {
        switch(
get_pcvar_num(cvar_show_hp))
        {
            case 
1: if(zp_get_user_zombie(id)) client_print(killer,print_center,"KILLED!")
            case 
2: if(zp_get_user_nemesis(id)) client_print(killer,print_center,"KILLED!")
            case 
3: if(zp_get_user_zombie(id) || zp_get_user_nemesis(id)) client_print(killer,print_center,"KILLED!")
        }
    }
}

public 
client_putinserver(id)
{
    
set_task(1.0,"load_user_data",id)
}

public 
client_disconnect(id)
{
    
save_user_data(id)
}

public 
load_user_data(id)
{
    if(!
is_user_connected(id)) return
    
    new 
user_data[64], vaultkey[64],vaultdata[256], data_ammo_packs[32],data_zombie_class[32]
    
    switch(
get_pcvar_num(cvar_data_save_type))
    {
        case 
1:
        {
            
get_user_ip(id,user_data,63)
            
format(vaultkey,63,"[ip]%s",user_data)
        }
        case 
2:
        {
            
get_user_authid(id,user_data,63)
            
format(vaultkey,63,"[aulthid]%s",user_data)
        }
        default:
        {
            
get_user_name(id,user_data,63)
            
format(vaultkey,63,"[name]%s",user_data)
        }
    }
    
    
format(vaultdata,255,"%i#%i#",zp_get_user_ammo_packs(id),zp_get_user_zombie_class(id))
    
nvault_get(data_vault,vaultkey,vaultdata,255)
    
replace_all(vaultdata,255,"#"," ")
    
    
parse(vaultdatadata_ammo_packs,31data_zombie_class,31)
    
zp_set_user_ammo_packs(idstr_to_num(data_ammo_packs))
    
zp_set_user_zombie_class(idstr_to_num(data_zombie_class))
    
    if(
get_pcvar_num(cvar_ammo_limit) != && zp_get_user_ammo_packs(id) > get_pcvar_num(cvar_ammo_limit)) zp_set_user_ammo_packs(id,get_pcvar_num(cvar_ammo_limit))
}

public 
save_user_data(id)
{
    new 
user_data[64], vaultkey[64],vaultdata[256]
    
    switch(
get_pcvar_num(cvar_data_save_type))
    {
        case 
1:
        {
            
get_user_ip(id,user_data,63)
            
format(vaultkey,63,"[ip]%s",user_data)
        }
        case 
2:
        {
            
get_user_authid(id,user_data,63)
            
format(vaultkey,63,"[aulthid]%s",user_data)
        }
        default:
        {
            
get_user_name(id,user_data,63)
            
format(vaultkey,63,"[name]%s",user_data)
        }
    }
    
    
format(vaultdata,255,"%i#%i#",zp_get_user_ammo_packs(id),zp_get_user_zombie_class(id))
    
nvault_set(data_vault,vaultkey,vaultdata)
}

/*START - From colorchat.inc by Numb */
ColorChat(idColor:type, const msg[], {FloatSqlResult,_}:...) {
    new 
message[256]

    switch(
type) {
        case 
NORMALmessage[0] = 0x01
        
case GREENmessage[0] = 0x04
        
default: message[0] = 0x03
    
}

    
vformat(message[1], 251msg4)

    
message[192] = '^0'

    
new teamColorChangeindexMSG_Type

    
if(id) {
        
MSG_Type MSG_ONE
        index 
id
    
} else {
        
index FindPlayer()
        
MSG_Type MSG_ALL
    
}

    
team get_user_team(index)
    
ColorChange ColorSelection(indexMSG_Typetype)

    
ShowColorMessage(indexMSG_Typemessage)

    if(
ColorChange)
        
Team_Info(indexMSG_TypeTeamName[team])
}

ShowColorMessage(idtypemessage[]) {
    static 
bool:saytext_used
    
static get_user_msgid_saytext

    
if(!saytext_used) {
        
get_user_msgid_saytext get_user_msgid("SayText")
        
saytext_used true
    
}

    
message_begin(typeget_user_msgid_saytext_id)
    
write_byte(id)
    
write_string(message)
    
message_end()
}

Team_Info(idtypeteam[]) {
    static 
bool:teaminfo_used
    
static get_user_msgid_teaminfo

    
if(!teaminfo_used) {
        
get_user_msgid_teaminfo get_user_msgid("TeamInfo")
        
teaminfo_used true
    
}

    
message_begin(typeget_user_msgid_teaminfo_id)
    
write_byte(id)
    
write_string(team)
    
message_end()

    return 
1
}

ColorSelection(indextypeColor:Type) {
    switch(
Type) {
        case 
RED: return Team_Info(indextypeTeamName[1])
        case 
BLUE: return Team_Info(indextypeTeamName[2])
        case 
GREY: return Team_Info(indextypeTeamName[0])
    }

    return 
0
}

FindPlayer() {
    new 
= -1

    
while(<= get_maxplayers()) {
        if(
is_user_connected(++i))
            return 
i
    
}

    return -
1
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1026\\ f0\\ fs16 \n\\ par }
*/ 
ASUS_BG is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode