这样修改对吗(杀人奖励插件)?(已解决)
本帖最后由 cityhonghu 于 2009-10-4 16:17 编辑虽然不是很懂,觉得连续杀人奖励部分有些不对改了一下(1局只能有1人?)。1楼为原始代码。2楼为改之后的代码,帮忙看一下是否对?
谢谢#include <amxmodx>
#include <unlimited_money>
new p_lastk=0,p_lastk_count=0
public plugin_init() {
register_plugin("MultiKill", "1.1", "Marshall")
register_event("DeathMsg", "hook_death", "a")
register_logevent("hook_roundstart",2,"0=World triggered","1=Round_Start")
}
public hook_death(){
new msg
new Killer = read_data(1)
new headshot = read_data(3)
new p_weapon
read_data(4,p_weapon,15)
new p_name
get_user_name(Killer,p_name,15)
//爆头奖励
if(headshot){
format(msg,127,"^x04爆头奖励:^x03%s^x01 获得$1000!",p_name)
client_color(Killer, Killer, msg)
cs_set_user_money2(Killer,cs_get_user_money2(Killer) + 1000)
}
//刀杀奖励
if(strcmp(p_weapon,"knife")==0){
format(msg,127,"^x04刀杀奖励:^x03%s^x01 获得$5000!",p_name)
client_color(Killer, Killer, msg)
cs_set_user_money2(Killer,cs_get_user_money2(Killer) + 5000)
}
//雷杀奖励
if(strcmp(p_weapon,"grenade")==0){
format(msg,127,"^x04雷杀奖励:^x03%s^x01 获得$1500!",p_name)
client_color(Killer, Killer, msg)
cs_set_user_money2(Killer,cs_get_user_money2(Killer) + 1500)
}
//连续杀人奖励
if(p_lastk != Killer){
p_lastk = Killer
p_lastk_count =1
}
else
p_lastk_count++
if(p_lastk_count>=5){
format(msg,127,"^x04连续杀人奖励:^x03%s^x01 连续杀人5次,获得$3000!",p_name)
client_color(Killer, Killer, msg)
cs_set_user_money2(Killer,cs_get_user_money2(Killer) + 3000)
}
}
public hook_roundstart(){
p_lastk=0
p_lastk_count=0
}
public client_color(playerid,colorid,msg[])
{
message_begin(playerid?MSG_ONE:MSG_ALL, get_user_msgid("SayText"), {0,0,0}, playerid)
write_byte(colorid)
write_string(msg)
message_end()
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang2052\\ f0\\ fs16 \n\\ par }
*/
修改之后,编译不通过。
问题:
1。数组的初始化(0)是不是要这样写?p_count =
2。killer = read_data(1)的话,被杀的人target是否为read_data(2) ?
以下为修改之后的代码。#include <amxmodx>
#include <unlimited_money>
new k_count =
public plugin_init() {
register_plugin("MultiKill", "1.1", "Marshall")
register_event("DeathMsg", "hook_death", "a")
register_logevent("hook_roundstart",2,"0=World triggered","1=Round_Start")
}
public hook_death(){
new msg
new Killer = read_data(1)
new headshot = read_data(3)
new p_weapon
read_data(4,p_weapon,15)
new p_name
get_user_name(Killer,p_name,15)
//爆头奖励
if(headshot){
format(msg,127,"^x04爆头奖励:^x03%s^x01 获得$1000!",p_name)
client_color(Killer, Killer, msg)
cs_set_user_money2(Killer,cs_get_user_money2(Killer) + 1000)
}
//刀杀奖励
if(strcmp(p_weapon,"knife")==0){
format(msg,127,"^x04刀杀奖励:^x03%s^x01 获得$5000!",p_name)
client_color(Killer, Killer, msg)
cs_set_user_money2(Killer,cs_get_user_money2(Killer) + 5000)
}
//雷杀奖励
if(strcmp(p_weapon,"grenade")==0){
format(msg,127,"^x04雷杀奖励:^x03%s^x01 获得$1500!",p_name)
client_color(Killer, Killer, msg)
cs_set_user_money2(Killer,cs_get_user_money2(Killer) + 1500)
}
//连续杀人奖励
k_count++
if(k_count>=5){
format(msg,127,"^x04连续杀人奖励:^x03%s^x01 连续杀人5次,获得$3000!",p_name)
client_color(Killer, Killer, msg)
cs_set_user_money2(Killer,cs_get_user_money2(Killer) + 3000)
k_count = 0
}
}
public hook_roundstart(){
k_count =
}
public client_color(playerid,colorid,msg[])
{
message_begin(playerid?MSG_ONE:MSG_ALL, get_user_msgid("SayText"), {0,0,0}, playerid)
write_byte(colorid)
write_string(msg)
message_end()
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang2052\\ f0\\ fs16 \n\\ par }
*/
晕,发错区了。麻烦版主移动到脚本编写讨论区。
真的对不起。 new k_count =
正常要寫成
new k_count = {0, 0, ...}
才對吧 谢谢,但是该行会出现如下错误,无法编译。
// E:\HLDS27016\cstrike\addons\amxmodx\scripting\kill_bonus.sma(61) : error 032:
array index out of bounds (variable "k_count") 第52行的部份你有改嗎? 问题已经解决了。使我的用法不对。
k_count = {0, 0, ...}初始化只能在定义阶段这样使用。
所以改为用for语句,对数组进行了归零。
页:
[1]