|
以前在点通下了个掉钱捡钱的插件,顺便连源代码也下来了,可是在修改源代码的时候怎么也编译不了,出现了这个错误:错误: Cannot read from file: "mysql" 在行 9
然后我就用他原来的没有修改过的代码也就是下面这个代码试着编译了一下,也编译不了,也是出现上面的那个错误,可这个插件至今都还在我的服里运行着的,想请教高手:怎么解决?
代码如下:/* Rewarding
ver 0.1 By Zhao on 2004.12.4
*/
#include <amxmodx>
#include <csx>
#include <amxmisc>
#include <cstrike>
#include <engine>
#include <mysql>
#include <csstats>
//#define DEBUG
#define MONEY_TIER 8000 // DON'T MESS WITH, Money total at which the plugin switches over keeping track of money
#define MAX_DROPED_MONEY_COUNT 100
#define TE_GLOWSPRITE 23
#define Maxsounds 1
#define BIG_MONEY_INDEX 16
#define OPEN_SQL
#define MONEY_REWARD
// coord, coord, coord (pos) short (model index) byte (scale / 10)
new soundlist[Maxsounds][] = {"Half-Life17"} //Connecting Music
new money_total[33] // Keep track of peeps money if above MONEY_TIER
new gmsg_Money
new playerkilled[33],teamjoined[33]
new rewards[20]={50,100,300,500,1000,3000,5000,8000,10000,15000,20000,25000,40000,50000,80000,100000,150000,200000,500000,900000}//Rewarding Ramdon
new g_firstblood,Round_Control
new g_random,g_roundcount
new g_money11,g_money22,g_money33
new rewardedbig,g_iRoundEndTriggered
//new connectingmp3
new droped_money_postion[MAX_DROPED_MONEY_COUNT][3]
new droped_money_ammount[MAX_DROPED_MONEY_COUNT][2]//[.][0] is money,[][1] is the round
new droped_money_count
new g_buffer[512]
public client_putinserver(id){
client_cmd(id,"mp3 stop")
return PLUGIN_CONTINUE
}
public team_join(){
new id=read_data(1)
// server_print("Ok, This Team_Join,id:%d",id)
if(teamjoined[id]) return
teamjoined[id]=1
new welcomemsg[129],username[33]
new izStats[8], izBody[8]
new iRankPos, iRankMax
get_user_name(id,username,32)
if (cvar_exists("csstats_reset")){
iRankPos = get_user_stats( id, izStats, izBody )
iRankMax = get_statsnum()
format(welcomemsg,128,"^x01欢迎^x03%s^x01,排名第^x04%d^x01名[共^x04%d^x01名]",username,iRankPos,iRankMax)
}else format(welcomemsg,128,"^x01欢迎^x03%s^x01,无排名",username)
client_color(0,id,welcomemsg)
}
public client_disconnect(id){
new name[32]
get_user_name(id,name,31)
format(g_buffer,511,"%s 离开了服务器.",name)
set_hudmessage(255, 150, 50, 0.10, 0.5, 0, 6.0, 10.0, 0.5, 0.15, 9)
show_hudmessage(0, g_buffer)
playerkilled[id]=0
return PLUGIN_CONTINUE
}
public abs(num){
return (num>=0)?num:-num
}
public client_connect(id){
new i
i = random_num(0,Maxsounds-1)
client_cmd(id,"mp3 play media/%s",soundlist)
set_cvar_float("mp_startmoney", 801.0) // So you can track when to change to amx_startmoney ammount, I know.. a crude method
money_total[id] = 0
//client_cmd(id,"mp3 play ^"../valve/media/half-life17.mp3^"");
}
public read_gmsg_Money(id)
{
new current_total = read_data(1)
if(current_total == 801){ // If CS is spawning you with mp_startmoney default
current_total = get_cvar_num("amx_startmoney") // current total is actually amx_startmoney
cs_set_user_money(id, current_total,0) // so set user money to amx_startmoney
money_total[id] = 0 // reset
}
if(current_total >= MONEY_TIER && !money_total[id]) // If first time above MONEY_TIER
{
money_total[id] = current_total // Keep track of current total
send_moneymsg(id,1) // send money msg of current total
return PLUGIN_CONTINUE
}
if(money_total[id]) // If was over tier on last money message
{
money_total[id] += current_total - MONEY_TIER // figure the term of current total - tier
if(money_total[id] < MONEY_TIER){ // If less then tier set user money to money_total[id] and stop keeping track
cs_set_user_money(id,money_total[id],1)
money_total[id] = 0
}
else{
send_moneymsg(id,1) // else send money message
}
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
public send_moneymsg(id,flash)
{
cs_set_user_money(id,MONEY_TIER,flash) //Set user money to tier ammount so easy to track add and subtract terms
static MAXAMMOUNT
MAXAMMOUNT = get_cvar_num("amx_maxmoney")
if(money_total[id] > MAXAMMOUNT)
money_total[id] = MAXAMMOUNT
message_begin( MSG_ONE , gmsg_Money , {0,0,0}, id) //Send money message with ammount stored in money_total[id]
write_long(money_total[id])
write_byte(flash)
message_end()
}
public ramdon_money(params[]){
new killer=params[0]
new oldamount=params[1]
new amount
new killername[32]
new random_range,randomvalue
random_range=(rewardedbig)?BIG_MONEY_INDEX:20//控制大额的奖励不会出现太多次
for(;;){
randomvalue=random(random_range)
amount=rewards[randomvalue]
if (amount!=oldamount) break;
}
get_user_name(killer,killername,31)
if (g_random>0){
g_random--
set_hudmessage(0,255,0,0.05,0.25,0, 0.02, 0.4, 0.01, 0.1, 2)
show_hudmessage(0,"%s一马当先,奋勇杀敌,奖励%6d金钱",killername,amount)
new param[2]
param[0]=killer
param[1]=amount
set_task(0.3,"ramdon_money",0,param,1)
}
else {
if(randomvalue>=BIG_MONEY_INDEX) rewardedbig=1
//set_hudmessage(0,255,0,0.75,0.18,0, 1.0, 5.0, 0.1, 0.2, 1)
set_hudmessage(0,255,0,0.05, 0.25, 0, 0.02, 6.0, 0.01, 0.1, 2)
show_hudmessage(0,"%s一马当先,奋勇杀敌,奖励%6d金钱",killername,amount)
add_player_money(killer,amount)
new msg[512]
format(msg,511,"^x03%s^x01 一马当先,奋勇杀敌,奖励^x04 %d ^x01金钱",killername,amount)
client_color(0,killer,msg)
}
}
public add_player_money(player,ammount){
static MAXAMMOUNT
MAXAMMOUNT = get_cvar_num("amx_maxmoney")
new new_total_money
if(money_total[player]){
new_total_money=money_total[player]+ammount
}
else
new_total_money=cs_get_user_money(player) + ammount
if (new_total_money>=MONEY_TIER){
money_total[player]=new_total_money
if(money_total[player]>MAXAMMOUNT) money_total[player]=MAXAMMOUNT
send_moneymsg(player,1) // send money msg of current total
}
else {
cs_set_user_money(player,new_total_money)
money_total[player]=0
}
}
public random_drop_money(ori_ammount){
new drop_control
if(ori_ammount>10000){
drop_control=random(100000)
if(ori_ammount>=drop_control){//按照钱的多少,我们产生不同的掉钱的随机数。
//现在我们决定要调多少。最多是0.6,0.5 0.4 0.3 0.2,0.1
return random(6)+1
}else return 0
}
return 0
}
//public client_death(killer,victim,wpnindex,hitplace,TK){
public eDeathMsg(){
new killer,victim,TK
killer=read_data(1)
if(!killer) return PLUGIN_CONTINUE
victim=read_data(2)
TK=(get_user_team(killer)==get_user_team(victim))?1:0
//headshot=read_data(3)
new wpnname[4]
read_data(4,wpnname,3)
new killername[32]
//if (wpnindex==CSW_C4||TK) return PLUGIN_CONTINUE
if(equal(wpnname,"c4")||TK) return PLUGIN_CONTINUE
// new headshot = ( hitplace==HIT_HEAD ) ? 1:0
new selfkill = ( killer==victim ) ? 1:0
if (selfkill) return PLUGIN_CONTINUE
playerkilled[killer]++
if(equal(wpnname,"kni")){
add_player_money(killer,10000)
get_user_name(killer,killername,31)
set_hudmessage(0,255,0,0.05,0.25,0, 0.2, 6.0, 0.1, 0.1, 2)
//set_hudmessage(0,255,0,0.75,0.18,0, 1.0, 1.0, 0.1, 0.2, 12)
show_hudmessage(0,"%s使用匕首杀敌,奖励10000金钱",killername)
new msg[100]
format(msg,99,"^x03%s^x01使用匕首杀敌,奖励^x04 10000 ^x01 金钱",killername)
client_color(0,killer,msg)
//log_message("%s使用匕首杀敌,奖励10000金钱",killername)
}
if (g_firstblood){
g_firstblood=0
g_random=6
new param[2]
param[0]=killer
param[1]=0;
ramdon_money(param)
}
//The Victim Will Drop Some Money
new victim_money
if(money_total[victim]==0) victim_money=cs_get_user_money(victim)
else victim_money=money_total[victim]
//if (victim_money>= MONEY_TIER&&
if (droped_money_count<MAX_DROPED_MONEY_COUNT){
new drop_prec=random_drop_money(victim_money)
//new int:dropedmoney=*victim_money
if(drop_prec>0){
new dropedmoney=(victim_money*drop_prec/10000)*1000
add_player_money(victim,-dropedmoney)
new victim_coord[3]
get_user_origin(victim, victim_coord)
new i
for (i=0;i<MAX_DROPED_MONEY_COUNT;i++)
{
if(droped_money_ammount[0]==0){
droped_money_count++
droped_money_postion[0]=victim_coord[0]
droped_money_postion[1]=victim_coord[1]
droped_money_postion[2]=victim_coord[2]
droped_money_ammount[1]=g_roundcount//We record which round droped the money
droped_money_ammount[0]=dropedmoney*8/10 //We Drop 20 precent money
break;
}
}
//new ammount_desc[32]
new victimname[32]
get_user_name(victim,victimname,31)
new msg[100]
format(msg,99,"^x03%s^x01掉了^x04%d^x01钱.",victimname,dropedmoney)
client_color(0,victim,msg)
}
}
return PLUGIN_CONTINUE
}
public show_droped_money(){
new i
new money_model_id
for (i=0;i<MAX_DROPED_MONEY_COUNT;i++){
if (droped_money_ammount[0]>0){
//We Display the money;
if(droped_money_ammount[0]<10000){
money_model_id=g_money11
}
else if (droped_money_ammount[0]<100000){
money_model_id=g_money22
} else money_model_id=g_money33
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(17)//#define TE_SPRITE 17 // additive sprite, plays 1 cycle,More Info,plz reffer to HLSDK
write_coord(droped_money_postion[0]);
write_coord(droped_money_postion[1]);
write_coord(droped_money_postion[2]+20);
write_short(money_model_id)
write_byte(2)
write_byte(128)
message_end()
}
}
}
public check_player_pos(){
new playerslist[32]
new i,playerscount,j,moneyammount
new playerspos[3],playername[32]
get_players(playerslist,playerscount,"a") //we only check the alive players
for(i=0;i<playerscount;i++){
get_user_origin(playerslist,playerspos)
for(j=0;j<MAX_DROPED_MONEY_COUNT;j++){
if(droped_money_ammount[j][0]>0&&
abs(playerspos[0]-droped_money_postion[j][0])<=20&&
abs(playerspos[1]-droped_money_postion[j][1])<=20&&
abs(playerspos[2]-droped_money_postion[j][2])<=30){//Pick Up Money
moneyammount=droped_money_ammount[j][0]
droped_money_ammount[j][0]=0;
droped_money_count--;
add_player_money(playerslist,moneyammount)
get_user_name(playerslist,playername,31)
new msg[100]
format(msg,99,"^x03%s^x01捡到^x04%d^x01钱.",playername,moneyammount);
client_color(0,playerslist,msg)
break;
}
}
}
}
public new_round(){
new i
if (!Round_Control){
g_roundcount++
Round_Control = 1
g_firstblood=1
g_iRoundEndTriggered=0
for(i=0;i<=32;i++)playerkilled=0;
//We Remove the droped money 3 round ago
for(i=0;i<MAX_DROPED_MONEY_COUNT;i++){
if (droped_money_ammount[0]>0&&g_roundcount>(droped_money_ammount[1]+2)){
droped_money_ammount[0]=0
droped_money_ammount[1]=0
droped_money_count--
}
}
}
}
public eEndRound(){
if (g_iRoundEndTriggered) return
g_iRoundEndTriggered=1
Round_Control=0
new i,maxkillcount
maxkillcount=0
new RoundEndMsg[513],ipos
new playerslist[32],playerscount
ipos=0
ipos+=format(RoundEndMsg[ipos],512-ipos,"本局杀敌最多的玩家")
get_players(playerslist,playerscount)//Get Players
for(i=0;i<playerscount;i++){
if(playerkilled[playerslist]&&playerkilled[playerslist]>maxkillcount) maxkillcount=playerkilled[playerslist]
}
if(maxkillcount){
new playername[33],playeradded=0
ipos+=format(RoundEndMsg[ipos],512-ipos," (杀%d人)^n---------------------------------^n",maxkillcount)
for(i=0;i<playerscount;i++){
if(playerkilled[playerslist]==maxkillcount){//WeiGet this players
if (get_user_name(playerslist,playername,32))
ipos+=format(RoundEndMsg[ipos],512-ipos,"%s^n",playername)
else ipos+=format(RoundEndMsg[ipos],512-ipos,"未知或已离开游戏^n")
++playeradded
}
if(playeradded>=2){
ipos+=format(RoundEndMsg[ipos],512-ipos,"......^n")
break;
}
}
}
else{
ipos+=format(RoundEndMsg[ipos],512-ipos,"^n---------------------------------^n大家太客气了,都没有杀敌^n")
}
ipos+=format(RoundEndMsg[ipos],512-ipos,"^n金钱最多的玩家^n---------------------------------^n")
new maxctmoney=0,maxtmoney=0,maxmoneytid=0,maxmoneyctid=0
for(i=0;i<playerscount;i++){
new userid=playerslist
new usermoney
if(!is_user_connected(userid)) continue
if(money_total[userid]) usermoney=money_total[userid]
else usermoney=cs_get_user_money(userid)
if(cs_get_user_team(userid)==CS_TEAM_T){
if(usermoney>maxtmoney){
maxtmoney=usermoney
maxmoneytid=userid
}
}
else {
if(usermoney>maxctmoney){
maxctmoney=usermoney
maxmoneyctid=userid
}
}
}
new ctname[33],tname[33]
if(maxmoneytid)get_user_name(maxmoneytid,tname,32)
else tname="没有人"
if(maxmoneyctid)get_user_name(maxmoneyctid,ctname,32)
else ctname="没有人"
ipos+=format(RoundEndMsg[ipos],512-ipos,"反恐小组^n%s %d^n恐怖分子^n%s %d",ctname,maxctmoney,tname,maxtmoney)
set_hudmessage( 100, 200, 0, 0.05, 0.55, 0, 0.02, 5.0, 0.1, 0.2, 2 )
show_hudmessage(0,RoundEndMsg)
}
public eRestart(){
new i
g_roundcount = 0
g_firstblood = 0
Round_Control = 0
rewardedbig = 0
for(i=0;i<=32;i++) money_total=0;
for(i=0;i<=32;i++)playerkilled=0;
for(i=0;i<MAX_DROPED_MONEY_COUNT;i++){
droped_money_ammount[0]=0
droped_money_ammount[1]=0
}
droped_money_count=0
// client_print(0,print_chat,"Round Restart and Roundcount=%d",g_roundcount)
}
public plugin_precache()
{
g_money11 = precache_model("sprites/money11.spr");
g_money22 = precache_model("sprites/money22.spr");
g_money33 = precache_model("sprites/money33.spr");
//precache_sound("../valve/media/half-life17.mp3");
}
public client_color(playerid,colorid,msg[]){
new playerslist[32],playerscount//,i
get_players(playerslist,playerscount,"c")
new userid
if(playerid==0){
userid=playerid
message_begin(MSG_ALL, get_user_msgid("SayText"), {0,0,0}, userid)
write_byte(colorid)
write_string(msg)
message_end()
}
else{
userid=playerid
message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, userid)
write_byte(colorid)
write_string(msg)
message_end()
}
}
public color_radio(msgid, msgDest, msgEnt){
new argNum = get_msg_args()
if (argNum!=5) return PLUGIN_CONTINUE
if (get_msg_argtype(1)!=ARG_BYTE) return PLUGIN_CONTINUE
new arg1=get_msg_arg_int(1)
if (arg1!=5) return PLUGIN_CONTINUE
new arg3[256]
get_msg_arg_string(3,arg3,255)
if(equal(arg3,"#Game_radio")){
new arg4[33],arg5[129]
get_msg_arg_string(4,arg4,32)
get_msg_arg_string(5,arg5,128)
new saymsg[256]
if(equal(arg5,"#Go_go_go")){//Msg GoGoGo
format(saymsg,255,"^x03%s(对讲机): ^x04Go go go!",arg4)
}
else if(equal(arg5,"#Stick_together_team")){
format(saymsg,255,"^x03%s(对讲机): ^x04Stick together, team.",arg4)
}
else if(equal(arg5,"#Team_fall_back")){
format(saymsg,255,"^x03%s(对讲机):^x04 Team, fall back!",arg4)
}
else if(equal(arg5,"#Cover_me")){
format(saymsg,255,"^x03%s(对讲机):^x04 Cover Me!",arg4)
}
else if(equal(arg5,"#You_take_the_point")){
format(saymsg,255,"^x03%s(对讲机):^x04 You Take the Point.",arg4)
}
else if(equal(arg5,"#Hold_this_position")){
format(saymsg,255,"^x03%s(对讲机):^x04 Hold This Position.",arg4)
}
else if(equal(arg5,"#Regroup_team")){
format(saymsg,255,"^x03%s(对讲机):^x04 Regroup Team.",arg4)
}
else if(equal(arg5,"#Follow_me")){
format(saymsg,255,"^x03%s(对讲机):^x04 Follow Me.",arg4)
}
else if(equal(arg5,"#Taking_fire")){
format(saymsg,255,"^x03%s(对讲机):^x04 Taking Fire...Need Assistance!",arg4)
}
else if(equal(arg5,"#Get_in_position_and_wait")){
format(saymsg,255,"^x03%s(对讲机):^x04 Get in position and wait for my go.",arg4)
}
else if(equal(arg5,"#Storm_the_front")){
format(saymsg,255,"^x03%s(对讲机):^x04 Storm the Front!",arg4)
}
else if(equal(arg5,"#Report_in_team")){
format(saymsg,255,"^x03%s(对讲机):^x04 Report in, team.",arg4)
}
else if(equal(arg5,"#Affirmative")){
format(saymsg,255,"^x03%s(对讲机):^x04 Affirmative.",arg4)
}
else if(equal(arg5,"#Roger_that")){
format(saymsg,255,"^x03%s(对讲机):^x04 Roger that.",arg4)
}
else if(equal(arg5,"#Enemy_spotted")){
format(saymsg,255,"^x03%s(对讲机):^x04 Enemy spotted.",arg4)
}
else if(equal(arg5,"#Need_backup")){
format(saymsg,255,"^x03%s(对讲机):^x04 Need backup.",arg4)
}
else if(equal(arg5,"#Sector_clear")){
format(saymsg,255,"^x03%s(对讲机):^x04 Sector clear.",arg4)
}
else if(equal(arg5,"#In_position")){
format(saymsg,255,"^x03%s(对讲机):^x04 I'm in position.",arg4)
}
else if(equal(arg5,"#Reporting_in")){
format(saymsg,255,"^x03%s(对讲机):^x04 Reporting in.",arg4)
}
else if(equal(arg5,"#Get_out_of_there")){
format(saymsg,255,"^x03%s(对讲机):^x04 Get out of there, it's gonna blow!",arg4)
}
else if(equal(arg5,"#Negative")){
format(saymsg,255,"^x03%s(对讲机):^x04 Negative.",arg4)
}
else if(equal(arg5,"#Enemy_down")){
format(saymsg,255,"^x03%s(对讲机):^x04 Enemy down.",arg4)
}
else if(equal(arg5,"#Hostage_down")){
format(saymsg,255,"^x03%s(对讲机):^x04 Hostage down.",arg4)
}
else if(equal(arg5,"#Fire_in_the_hole")){
format(saymsg,255,"^x03%s(对讲机):^x04 Fire in the hole!",arg4)
}
else {
return PLUGIN_CONTINUE
//format(saymsg,255,"^x03%s(对讲机): ^x04What are you saying!",arg4)
}
message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, msgEnt)
write_byte(msgEnt)
write_string(saymsg)
message_end()
//client_color(0,msgEnt,saymsg)
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public plugin_init(){
register_plugin("First Killer Reward","0.1","Zhao")
register_event("RoundTime", "new_round", "bc")
// register_event("ResetHUD", "new_round", "abc")
#if defined MONEY_REWARD
register_event("DeathMsg","eDeathMsg","a")
register_event("Money","read_gmsg_Money","b")
#endif
register_event("SendAudio", "eEndRound", "a", "2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw")
register_event("TextMsg","eRestart","a","2&#Game_C","2&#Game_w")
// register_event("BarTime","bartime_event","b")
register_cvar("amx_startmoney", "800")
register_cvar("amx_maxmoney", "999999")
register_message(get_user_msgid("TextMsg"),"color_radio")
register_event("TeamInfo","team_join","a","2!UNASSIGNED") // Team Joining
g_firstblood=1
rewardedbig = 0
droped_money_count=0
g_roundcount=0
gmsg_Money = get_user_msgid("Money")
#if defined MONEY_REWARD
set_task(0.5,"show_droped_money",887,"",0,"b")
set_task(0.1,"check_player_pos",888,"",0,"b")
#endif
} |
|