|
Junior Member
Join Date: Aug 2005
Location: Right Behind You
|

08-30-2005
, 23:20
SurfTag I need some help.
|
#1
|
Ok folks, I've been looking at other scriper's scripts for about a month now and just diving into whatever I can get my hands on to teach myself small. i've been mostly looking at kz_multiplugin.sma and some of the standard amx plugins such as admin_chat.sma. This is the first code that i have written completely by myself (Tiny bit of help from v3x in the past hour) and i want to see what im doing wrong, and some errors that i am having need to be resolved. This is a "tag" plugin for a Surf *RESPAWN* server, so there are some things in here that you may not be farmiliar with.
The basic idea of this plugin is as follows:
-If a game of tag is not in progress, ANY player on the server can say "tag" and a random player will be chosen as "it".
-When you are "it" you glow green, are given a deagle with full ammo, and are blessed with a timer set at 60 seconds.
-If you can remain "it" for those 60 seconds without being touched (tagged) by a player on the opposite team, then you are awarded with a red glow, and an AWP.
-If you DIE while you are "it", the timer is reset.
-If the player that is "it" leaves the server, a new player is chosen to be "it" at random.
Some of my problems are as follows:
-Sometimes when a non-it player tags the person who is "it" the new "it" player does not see a timer.
-When a player dies that is it and the round resets, the timer is not displayed
-Spectators become it *SOLVED* // thanks v3x
I know that you guys are good at this stuff, so i'd like some feedback on how i am doing, and some fixes for my plugin. The people on my server would be very glad.
Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>
#include <fun>
new It[33]
new count[33]
public plugin_init(){
register_plugin("SurfTag","1.0","-Default-")
register_clcmd("say", "HandleSay")
register_event("DeathMsg", "DeathMsg", "a")
set_task(1.0,"checkglow",_,_,_,"b")
return PLUGIN_CONTINUE
}
public client_connect(id) {
It[id] = 0
return PLUGIN_CONTINUE
}
public client_disconnect(id){
if(It[id] == 1){
set_task(0.1,"RandomIt")
remove_task(id)
}
It[id] = 0
return PLUGIN_CONTINUE
}
public checkglow() {
new players[32], num, i, player
get_players(players,num)
for(i=0;i<num;i++) {
player = players[i]
if(It[player] == 0) {
set_user_rendering(player,kRenderFxGlowShell,0,0,0,kRenderNormal,25)
}
}
}
public RandomIt(id) {
new name[32]
new players[32], num, i, player
get_players(players,num)
for(i=0;i<num;i++) {
player = players[i]
if(It[player] == 1) {
get_user_name(player, name, 31)
client_print(id,print_chat,"[TagBot]: %s is already it!!!!",name)
return PLUGIN_HANDLED
}
}
new free = players[random_num(0,num-1)]
It[free] = 1
set_task(0.1,"Setglowdeagle",free)
client_print(id,print_chat,"[TagBot]: New Player Set as It")
get_players(players,num,"c");
new name_it[32]
get_user_name(free, name_it, 31)
for(i = 0; i <=num; i++){
if(!is_user_connected(players[i]) || players[i] == free) continue;
client_print(players[i],print_center,"%s is it!", name_it);
}
return PLUGIN_CONTINUE
}
public HandleSay(id) {
new Speech[192]
read_args(Speech,191)
remove_quotes(Speech)
if((containi(Speech, "tag") != -1)){
set_task(0.1,"RandomIt",id)
}
return PLUGIN_CONTINUE
}
public pfn_touch(ptr, ptd) {
new team1 = get_user_team(ptr)
new team2 = get_user_team(ptd)
if ((ptr > 0) && (ptd > 0) && is_valid_ent(ptr) && is_valid_ent(ptd)) {
new classname_ptr[32], classname_ptd[32]
entity_get_string(ptr, EV_SZ_classname, classname_ptr, 31)
entity_get_string(ptd, EV_SZ_classname, classname_ptd, 31)
if (equal(classname_ptr, "player") && equal(classname_ptd, "player")) {
if((team1 == 1 && team2 == 2) || (team1 == 2 && team2 == 1)){
if(It[ptd] == 1 && It[ptr] == 0){
set_user_rendering(ptd,kRenderFxGlowShell,0,0,0,kRenderNormal,25)
It[ptr] = 1
It[ptd] = 2
set_task(1.0,"SetIt",ptd)
set_task(0.1,"Setglowdeagle",ptr)
new players[32],num,i;
get_players(players,num,"c");
new name_it[32]
get_user_name(ptr, name_it, 31)
for(i = 0; i <=num; i++){
if(!is_user_connected(players[i]) || players[i] == ptr) continue;
client_print(players[i],print_center,"%s is it!", name_it);
}
}
}
}
}
}
public SetIt(ptd) {
if(It[ptd] == 2){
It[ptd] = 0
}
}
public DeathMsg() {
new died = read_data(2) // Get the victims user id
if(It[died] == 1){
set_task(0.5,"Setglowdeagle",died)
//Setglowdeagle(died)
}
}
public Setglowdeagle(died) {
if(is_user_alive(died) == 1){
//new name_died[32]
//get_user_name(died, name_died, 31)
//client_print(0,print_center,"%s is it!", name_died)
remove_task(died)
give_item(died,"weapon_deagle")
give_item(died,"ammo_50ae")
give_item(died,"ammo_50ae")
give_item(died,"ammo_50ae")
give_item(died,"ammo_50ae")
give_item(died,"ammo_50ae")
give_item(died,"ammo_50ae")
give_item(died,"ammo_50ae")
set_user_rendering(died,kRenderFxGlowShell,0,255,0,kRenderNormal,25)
count[died] = 60
set_task(0.1,"Countdown",died)
//Countdown(died)
}
else {
set_task(0.1,"Setglowdeagle",died)
}
}
public Countdown(ptr,died){
if((It[ptr] == 1) && (count[ptr] != 0) && (is_user_alive(ptr) == 1)){
client_print(ptr,print_center,"Timer: %d Seconds Till AWP", count[ptr])
set_task(1.0,"Countdown",ptr)
--count[ptr]
}
else if(count[ptr] == 0){
new name_ptr[32]
client_cmd(ptr,"spk buttons/blip2")
get_user_name(ptr, name_ptr, 31)
client_print(ptr,print_chat,"[TagBot]: You've been it for 60 secs. Here's an AWP!")
client_print(0,print_center,"%s has been it for 60 seconds! They get an AWP!",name_ptr)
give_item(ptr,"weapon_awp")
give_item(ptr,"ammo_338magnum")
give_item(ptr,"ammo_338magnum")
give_item(ptr,"ammo_338magnum")
set_user_rendering(ptr,kRenderFxGlowShell,255,0,0,kRenderNormal,25)
}
else{
set_task(0.2,"Countdown",ptr)
}
}
__________________
|
|