Raised This Month: $ Target: $400
 0% 

Edit script Public Rules on Death & Join


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kitami
Senior Member
Join Date: Jun 2006
Location: Toronto
Old 08-18-2008 , 15:45   Edit script Public Rules on Death & Join
Reply With Quote #1

I just wanted to add a cvar into this script so that you can make it so it only pops up when your dead and not when your alive, because with a really small res like 800x600 or 640x480 it blocks the whole screen.


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

new base[] = "rules.txt"

new inumtext[127], hudmsg[440//max hudmessage length was 439 chars (?)

public plugin_init()
{
    
    
register_plugin("AMXX Public server rules""1.20""Priski")
    
    
// register command
    
    
register_concmd("rules_show""rules"ADMIN_KICK"- show rules to everybody")
    
register_concmd("rules_enable""r_enable"ADMIN_KICK"- <1|0> set automessagin on/off")
    
register_cvar("rules_admin_only""0")
    
register_cvar("rules_join""1")
    
register_cvar("rules_join_timeout""5")
    
register_cvar("rules_hudmessage_time""10")
    
register_cvar("rules_interval""600")
    
register_clcmd("say /rules""clientrules"ADMIN_ALL"- show rules")


public 
plugin_cfg() {
    
    if (!
file_exists(base)) {
        
write_file(base"; This is the public rules file, put your rules below")
        
write_file(base"; Remember, max amount of characters is 439")
        
console_print(0"%s file not found. creating new ..."base)
    }
    
}

public 
client_authorized id ) {
    
// on join display rules
    
    
if (get_cvar_num("rules_join")) {
        new 
tmp[1]
        
tmp[0] = id
        set_task
(1.0"showrules",id,tmp,1)
        
console_print(0"[user %d] client auth!"tmp[0])
    }
    
    return 
PLUGIN_HANDLED
}


public 
showrules (pid[]) {
    new 
id pid[0]
    
    if ( 
get_user_team(id) != && get_user_team(id) != ) {
        if (
id) {
            new 
tmp[1]
            
tmp[0] = id
            set_task
(2.0"showrules",id,tmp,1)  // not yet in server
            
console_print(0"[user %d] wait for joining team ..."id)
        }
        return 
PLUGIN_HANDLED
    
}
    
    new 
tmp[1]
    
tmp[0] = id
    
    console_print
(0"[user %d] joined team : %d"idget_user_team(id))
    
console_print(0"[user %d] printing rules after %d seconds"idget_cvar_num("rules_join_timeout"))
    
    
set_task(get_cvar_float("rules_join_timeout"), "printrules"idtmp1)  // not yet in server
    
    
return PLUGIN_HANDLED
}

public 
printrules(pid[])
{
    new 
id pid[0]
    if (
file_exists(base))
        {
        
        
console_print(0"[user] printing rules for user %d"id)
        
        
set_hudmessage 20015000.020.2520.1get_cvar_float("rules_hudmessage_time"), 0.051.01)
        
format(hudmsg439"")
        
        
// read all the rules
        
for(i=0read_file(baseitext127num); i++) {
            if (
num && text[0] != ';') {
                
// display with predefined delay
                
add(hudmsg,439,text)
                
add(hudmsg,439,"^n")
            }
        }
        
        
// show hudmessages
        
show_hudmessage(idhudmsg)
        
    }
    
    return 
PLUGIN_HANDLED
}


public 
r_enable(idlevelcid)
{
    if (!
cmd_access(idlevelcid0)) {  // NOT ADMIN
        
return PLUGIN_HANDLED
    
}
    
    new 
arg[3]
    
    
read_argv(1arg2)
    new 
value str_to_num(arg)
    
    if (!
isalnum(arg[0]))
        
value = -1
    
    
if (value == 0) {
        
        if (
task_exists(2)) // close task
            
remove_task(2)    
        
        
console_print(id"You have disabled automatic messages")
        return 
PLUGIN_HANDLED
        
    
}
    if (
value == 1) {
        
// activate task, reload if already exist
        
if (task_exists(2)) {
            
change_task(2get_cvar_float("rules_interval"))
            } else {
            
set_task(get_cvar_float("rules_interval"), "rules"2""0"b")
        }    
        
console_print(id"You have enabled automatic messages")
        return 
PLUGIN_HANDLED        
    
}
    if (
task_exists(2)) {
        
console_print(id"automessages is ON.")
        } else {
        
console_print(id"automessages is OFF.")
    }
    
console_print(id"rules_enable <1|0> (1 = ON, 0 = OFF)")
    return 
PLUGIN_HANDLED        
    
}

public 
clientrules(idlevelcid) {
    new 
pID[1]
    
pID[0] = id
    
    console_print
(0,"[user %d]Print rules for me only",pID[0])
    
printrules(pID[0])
}

public 
rules(idlevelcid)
{
    new 
pID[1]
    
pID[0] = id
            
    
if (!cmd_access(idlevelcid0)) {  // NOT ADMIN
        
return PLUGIN_HANDLED
    
}
    
    
// read file to all users
    
pID[0] = 0
    console_print
(0,"[user %d]Print rules for all",id)
    
printrules(pID[0])
    
    
// Reset scheduled task after display
    
if (get_cvar_float("rules_interval") > 0) {
        if (
task_exists(2)) {
            
change_task(2get_cvar_float("rules_interval"))
            } else {
            
set_task(get_cvar_float("rules_interval"), "rules"200""0"b")
        }
    }
    
    return 
PLUGIN_HANDLED

__________________
You know what I'd like to be? I mean if I had my goddamn choice, I'd just be the catcher in the rye and all.
Kitami is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 08-18-2008 , 19:55   Re: Edit script Public Rules on Death & Join
Reply With Quote #2

all you had to do was to add a simple cvar and to make an if statment to see if it's set to 1. if so, you check if user is alive. if not, nothing will happen. but since i had nothing better to do i did that for ya

PHP Code:
#include <amxmodx>
#include <amxmisc>
new base[] = "rules.txt"
new inumtext[127], hudmsg[440//max hudmessage length was 439 chars (?)
new DeathMsg;
public 
plugin_init()
{
 
    
register_plugin("AMXX Public server rules""1.20""Priski")
 
    
// register command
 
    
register_concmd("rules_show""rules"ADMIN_KICK"- show rules to everybody")
    
register_concmd("rules_enable""r_enable"ADMIN_KICK"- <1|0> set automessagin on/off")
    
register_cvar("rules_admin_only""0")
    
register_cvar("rules_join""1")
    
register_cvar("rules_join_timeout""5")
    
register_cvar("rules_hudmessage_time""10")
    
register_cvar("rules_interval""600")
    
register_cvar("rules_show_dead""1"// if set to 1 (default), rules will be only showed if the player is dead. (dor123)
    
register_clcmd("say /rules""clientrules"ADMIN_ALL"- show rules")

public 
plugin_cfg() {
 
    if (!
file_exists(base)) {
        
write_file(base"; This is the public rules file, put your rules below")
        
write_file(base"; Remember, max amount of characters is 439")
        
console_print(0"%s file not found. creating new ..."base)
    }
 
}
public 
client_authorized id ) {
    
// on join display rules
 
    
if (get_cvar_num("rules_join")) {
        new 
tmp[1]
        
tmp[0] = id
        set_task
(1.0"showrules",id,tmp,1)
        
console_print(0"[user %d] client auth!"tmp[0])
    }
 
    return 
PLUGIN_HANDLED
}
 
public 
showrules (pid[]) {
    new 
id pid[0]
 
    if ( 
get_user_team(id) != && get_user_team(id) != ) {
        if (
id) {
            new 
tmp[1]
            
tmp[0] = id
            set_task
(2.0"showrules",id,tmp,1)  // not yet in server
            
console_print(0"[user %d] wait for joining team ..."id)
        }
        return 
PLUGIN_HANDLED
    
}
 
    new 
tmp[1]
    
tmp[0] = id
 
    console_print
(0"[user %d] joined team : %d"idget_user_team(id))
    
console_print(0"[user %d] printing rules after %d seconds"idget_cvar_num("rules_join_timeout"))
 
    
set_task(get_cvar_float("rules_join_timeout"), "printrules"idtmp1)  // not yet in server
 
    
return PLUGIN_HANDLED
}
public 
printrules(pid[])
{
    new 
id pid[0]
    if (
file_exists(base))
        {
 
        
console_print(0"[user] printing rules for user %d"id)
 
        
set_hudmessage 20015000.020.2520.1get_cvar_float("rules_hudmessage_time"), 0.051.01)
        
format(hudmsg439"")
 
        
// read all the rules
        
for(i=0read_file(baseitext127num); i++) {
            if (
num && text[0] != ';') {
                
// display with predefined delay
                
add(hudmsg,439,text)
                
add(hudmsg,439,"^n")
            }
        }
 
        
// show hudmessages
        
show_hudmessage(idhudmsg)
 
    }
 
    return 
PLUGIN_HANDLED
}
 
public 
r_enable(idlevelcid)
{
    if (!
cmd_access(idlevelcid0)) {  // NOT ADMIN
        
return PLUGIN_HANDLED
    
}
 
    new 
arg[3]
 
    
read_argv(1arg2)
    new 
value str_to_num(arg)
 
    if (!
isalnum(arg[0]))
        
value = -1
 
    
if (value == 0) {
 
        if (
task_exists(2)) // close task
            
remove_task(2)    
 
        
console_print(id"You have disabled automatic messages")
        return 
PLUGIN_HANDLED
 
    
}
    if (
value == 1) {
        
// activate task, reload if already exist
        
if (task_exists(2)) {
            
change_task(2get_cvar_float("rules_interval"))
            } else {
            
set_task(get_cvar_float("rules_interval"), "rules"2""0"b")
        }    
        
console_print(id"You have enabled automatic messages")
        return 
PLUGIN_HANDLED        
    
}
    if (
task_exists(2)) {
        
console_print(id"automessages is ON.")
        } else {
        
console_print(id"automessages is OFF.")
    }
    
console_print(id"rules_enable <1|0> (1 = ON, 0 = OFF)")
    return 
PLUGIN_HANDLED        
 
}
public 
clientrules(idlevelcid) {
    new 
pID[1]
    
pID[0] = id
 
    
if( get_cvar_num("rules_show_dead") ){
 
         if( !
is_user_alive ){     // Added by dor123 to make sure a player can only use the command if he's dead.
 
              
console_print(0,"[user %d]Print rules for me only",pID[0])
              
printrules(pID[0])
         }
 
         else {
 
              
client_print(pID[0], print_chat"You can only use that command when you're dead."); // if user is alive, do nothing (we DON'T need to return PLUGIN_HANDLED;).
         
}
    }
}
public 
rules(idlevelcid)
{
    new 
pID[1]
    
pID[0] = id
 
    
if (!cmd_access(idlevelcid0)) {  // NOT ADMIN
        
return PLUGIN_HANDLED
    
}
 
    
// read file to all users
    
pID[0] = 0
    console_print
(0,"[user %d]Print rules for all",id)
    
printrules(pID[0])
 
    
// Reset scheduled task after display
    
if (get_cvar_float("rules_interval") > 0) {
        if (
task_exists(2)) {
            
change_task(2get_cvar_float("rules_interval"))
            } else {
            
set_task(get_cvar_float("rules_interval"), "rules"200""0"b")
        }
    }
 
    return 
PLUGIN_HANDLED

if it doesn't work tell me. (not tested)

EDIT: BTW, if I didn't understand exactly what you wanted, also tell me .
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 08-18-2008 at 20:00.
Dores is offline
Kitami
Senior Member
Join Date: Jun 2006
Location: Toronto
Old 08-22-2008 , 03:04   Re: Edit script Public Rules on Death & Join
Reply With Quote #3

PHP Code:
//// public_rules.sma
// F:\amxmodx\scripting\public_rules.sma(144) : error 076: syntax error in the e
xpression, or invalid function call
// F:\amxmodx\scripting\public_rules.sma(180) : warning 203: symbol is never use
d"DeathMsg"
//
// 1 Error.
// Could not locate output file compiled\public_rules.amx (compile failed).
//
// Compilation Time: 0.39 sec
// ---------------------------------------- 
__________________
You know what I'd like to be? I mean if I had my goddamn choice, I'd just be the catcher in the rye and all.
Kitami is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 08-22-2008 , 07:46   Re: Edit script Public Rules on Death & Join
Reply With Quote #4

Fixed
PHP Code:
#include <amxmodx>
#include <amxmisc>
new base[] = "rules.txt"
new inumtext[127], hudmsg[440//max hudmessage length was 439 chars (?)
public plugin_init()
{
 
    
register_plugin("AMXX Public server rules""1.20""Priski")
 
    
// register command
 
    
register_concmd("rules_show""rules"ADMIN_KICK"- show rules to everybody")
    
register_concmd("rules_enable""r_enable"ADMIN_KICK"- <1|0> set automessagin on/off")
    
register_cvar("rules_admin_only""0")
    
register_cvar("rules_join""1")
    
register_cvar("rules_join_timeout""5")
    
register_cvar("rules_hudmessage_time""10")
    
register_cvar("rules_interval""600")
    
register_cvar("rules_show_dead""1"// if set to 1 (default), rules will be only showed if the player is dead. (dor123)
    
register_clcmd("say /rules""clientrules"ADMIN_ALL"- show rules")

public 
plugin_cfg() {
 
    if (!
file_exists(base)) {
        
write_file(base"; This is the public rules file, put your rules below")
        
write_file(base"; Remember, max amount of characters is 439")
        
console_print(0"%s file not found. creating new ..."base)
    }
 
}
public 
client_authorized id ) {
    
// on join display rules
 
    
if (get_cvar_num("rules_join")) {
        new 
tmp[1]
        
tmp[0] = id
        set_task
(1.0"showrules",id,tmp,1)
        
console_print(0"[user %d] client auth!"tmp[0])
    }
 
    return 
PLUGIN_HANDLED
}
 
public 
showrules (pid[]) {
    new 
id pid[0]
 
    if ( 
get_user_team(id) != && get_user_team(id) != ) {
        if (
id) {
            new 
tmp[1]
            
tmp[0] = id
            set_task
(2.0"showrules",id,tmp,1)  // not yet in server
            
console_print(0"[user %d] wait for joining team ..."id)
        }
        return 
PLUGIN_HANDLED
    
}
 
    new 
tmp[1]
    
tmp[0] = id
 
    console_print
(0"[user %d] joined team : %d"idget_user_team(id))
    
console_print(0"[user %d] printing rules after %d seconds"idget_cvar_num("rules_join_timeout"))
 
    
set_task(get_cvar_float("rules_join_timeout"), "printrules"idtmp1)  // not yet in server
 
    
return PLUGIN_HANDLED
}
public 
printrules(pid[])
{
    new 
id pid[0]
    if (
file_exists(base))
        {
 
        
console_print(0"[user] printing rules for user %d"id)
 
        
set_hudmessage 20015000.020.2520.1get_cvar_float("rules_hudmessage_time"), 0.051.01)
        
format(hudmsg439"")
 
        
// read all the rules
        
for(i=0read_file(baseitext127num); i++) {
            if (
num && text[0] != ';') {
                
// display with predefined delay
                
add(hudmsg,439,text)
                
add(hudmsg,439,"^n")
            }
        }
 
        
// show hudmessages
        
show_hudmessage(idhudmsg)
 
    }
 
    return 
PLUGIN_HANDLED
}
 
public 
r_enable(idlevelcid)
{
    if (!
cmd_access(idlevelcid0)) {  // NOT ADMIN
        
return PLUGIN_HANDLED
    
}
 
    new 
arg[3]
 
    
read_argv(1arg2)
    new 
value str_to_num(arg)
 
    if (!
isalnum(arg[0]))
        
value = -1
 
    
if (value == 0) {
 
        if (
task_exists(2)) // close task
            
remove_task(2)    
 
        
console_print(id"You have disabled automatic messages")
        return 
PLUGIN_HANDLED
 
    
}
    if (
value == 1) {
        
// activate task, reload if already exist
        
if (task_exists(2)) {
            
change_task(2get_cvar_float("rules_interval"))
            } else {
            
set_task(get_cvar_float("rules_interval"), "rules"2""0"b")
        }    
        
console_print(id"You have enabled automatic messages")
        return 
PLUGIN_HANDLED        
    
}
    if (
task_exists(2)) {
        
console_print(id"automessages is ON.")
        } else {
        
console_print(id"automessages is OFF.")
    }
    
console_print(id"rules_enable <1|0> (1 = ON, 0 = OFF)")
    return 
PLUGIN_HANDLED        
 
}
public 
clientrules(idlevelcid) {
    new 
pID[1]
    
pID[0] = id
 
    
if( get_cvar_num("rules_show_dead") ){
 
         if( 
is_user_alive(pID[0]) ){     // Added by dor123 to make sure a player can only use the command if he's dead.
 
               
client_print(pID[0], print_chat"You can only use that command when you're dead."); // if user is alive, do nothing (we DON'T need to return PLUGIN_HANDLED;).
         
}
    }
 
    else {
                  
console_print(0,"[user %d]Print rules for me only",pID[0])
                  
printrules(pID[0])
    }
}
public 
rules(idlevelcid)
{
    new 
pID[1]
    
pID[0] = id
 
    
if (!cmd_access(idlevelcid0)) {  // NOT ADMIN
        
return PLUGIN_HANDLED
    
}
 
    
// read file to all users
    
pID[0] = 0
    console_print
(0,"[user %d]Print rules for all",id)
    
printrules(pID[0])
 
    
// Reset scheduled task after display
    
if (get_cvar_float("rules_interval") > 0) {
        if (
task_exists(2)) {
            
change_task(2get_cvar_float("rules_interval"))
            } else {
            
set_task(get_cvar_float("rules_interval"), "rules"200""0"b")
        }
    }
 
    return 
PLUGIN_HANDLED

Note that I only changed it so when a player uses the client command that shows the rules, he will only see them if he's dead. Everything else is left as before. If you want me to change something else or I mis-understood you, tell me
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 08-22-2008 at 07:52.
Dores is offline
Kitami
Senior Member
Join Date: Jun 2006
Location: Toronto
Old 08-27-2008 , 18:10   Re: Edit script Public Rules on Death & Join
Reply With Quote #5

I wanted it the other way around, client can use command when ever he wants, but if clients doesn't use the command it will only pop-up while the client is dead.
__________________
You know what I'd like to be? I mean if I had my goddamn choice, I'd just be the catcher in the rye and all.
Kitami is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 08-28-2008 , 08:16   Re: Edit script Public Rules on Death & Join
Reply With Quote #6

I've made it the way you wanted - I added a cvar (rules_dead_only) and when it's set to 1, it will only print rules if player is dead. I also made it so it will print to a player when he dies, as long as he didn't use the "say /rules" command.
PHP Code:
#include <amxmodx>
#include <amxmisc>

new base[] = "rules.txt"

new inumtext[127], hudmsg[440//max hudmessage length was 439 chars (?)
new bool:g_sawrules[33]; // add by dor123 to check if used the /rules command in the current round

public plugin_init()
{
    
    
register_plugin("AMXX Public server rules""1.20""Priski")
    
    
// register command
    
    
register_concmd("rules_show""rules"ADMIN_KICK"- show rules to everybody")
    
register_concmd("rules_enable""r_enable"ADMIN_KICK"- <1|0> set automessagin on/off")
    
register_cvar("rules_admin_only""0")
    
register_cvar("rules_join""1")
    
register_cvar("rules_join_timeout""5")
    
register_cvar("rules_hudmessage_time""10")
    
register_cvar("rules_interval""600")
    
register_clcmd("say /rules""clientrules"ADMIN_ALL"- show rules")
    
register_cvar("rules_dead_only""1"); // added by dor12 3to make sure it will only show rules if player is dead
    
    
register_event("DeathMsg""player_died""a"); // dor123
    
register_event("HLTV""newRound""a""1=0""2=0"); // dor123
    
}

public 
plugin_cfg() {
    
    if (!
file_exists(base)) {
        
write_file(base"; This is the public rules file, put your rules below")
        
write_file(base"; Remember, max amount of characters is 439")
        
console_print(0"%s file not found. creating new ..."base)
    }
    
}

public 
client_authorized id ) {
    
// on join display rules
    
    
if (get_cvar_num("rules_join")) {
        new 
tmp[1]
        
tmp[0] = id
        set_task
(1.0"showrules",id,tmp,1)
        
console_print(0"[user %d] client auth!"tmp[0])
    }
    
    return 
PLUGIN_HANDLED
}

public 
showrules (pid[]) {
    new 
id pid[0]
    
    if ( 
get_user_team(id) != && get_user_team(id) != ) {
        if (
id) {
            new 
tmp[1]
            
tmp[0] = id
            set_task
(2.0"showrules",id,tmp,1)  // not yet in server
            
console_print(0"[user %d] wait for joining team ..."id)
        }
        return 
PLUGIN_HANDLED
    
}
    
    new 
tmp[1]
    
tmp[0] = id
    
    console_print
(0"[user %d] joined team : %d"idget_user_team(id))
    
console_print(0"[user %d] printing rules after %d seconds"idget_cvar_num("rules_join_timeout"))
    
    
set_task(get_cvar_float("rules_join_timeout"), "printrules"idtmp1)  // not yet in server
    
    
return PLUGIN_HANDLED
}

public 
printrules(pid[])
{
    new 
id pid[0]
    if (
file_exists(base)){
        
        
// if only dead cvar is set to 1, the player will see the rules only if he's dead (dor123)
          
if(get_cvar_num("rules_dead_only") && !is_user_alive(id)){
        
                  
console_print(0"[user] printing rules for user %d"id)
        
                  
set_hudmessage 20015000.020.2520.1get_cvar_float("rules_hudmessage_time"), 0.051.01)
                  
format(hudmsg439"")
        
                  
// read all the rules
                  
for(i=0read_file(baseitext127num); i++) {
              
                           if (
num && text[0] != ';') {
                  
                                    
// display with predefined delay
                                    
add(hudmsg,439,text)
                                    
add(hudmsg,439,"^n")
                           }
                  }
        
                  
// show hudmessages
                  
show_hudmessage(idhudmsg)
          }
    
          
// if only dead cvar is set to 1 and user is alive, command won't execute (dor123)
          
else if(get_cvar_num("rules_dead_only") && is_user_alive(id)){
        
                
client_print(idprint_chat"Can only show rules to dead players.");
                return 
PLUGIN_HANDLED;
          }
    
          else if(!
get_cvar_num("rules_dead_only")){
        
                
console_print(0"[user] printing rules for user %d"id)
        
                
set_hudmessage 20015000.020.2520.1get_cvar_float("rules_hudmessage_time"), 0.051.01)
                
format(hudmsg439"")
        
                
// read all the rules
                
for(i=0read_file(baseitext127num); i++) {
              
                           if (
num && text[0] != ';') {
                  
                                    
// display with predefined delay
                                    
add(hudmsg,439,text)
                                    
add(hudmsg,439,"^n")
                           }
                }
        
                
// show hudmessages
                
show_hudmessage(idhudmsg)
          }
        
    }
    
    return 
PLUGIN_HANDLED
}


public 
r_enable(idlevelcid)
{
    if (!
cmd_access(idlevelcid0)) {  // NOT ADMIN
        
return PLUGIN_HANDLED
    
}
    
    new 
arg[3]
    
    
read_argv(1arg2)
    new 
value str_to_num(arg)
    
    if (!
isalnum(arg[0]))
        
value = -1
    
    
if (value == 0) {
        
        if (
task_exists(2)) // close task
            
remove_task(2)    
        
        
console_print(id"You have disabled automatic messages")
        return 
PLUGIN_HANDLED
        
    
}
    if (
value == 1) {
        
// activate task, reload if already exist
        
if (task_exists(2)) {
            
change_task(2get_cvar_float("rules_interval"))
            } else {
            
set_task(get_cvar_float("rules_interval"), "rules"2""0"b")
        }    
        
console_print(id"You have enabled automatic messages")
        return 
PLUGIN_HANDLED        
    
}
    if (
task_exists(2)) {
        
console_print(id"automessages is ON.")
        } else {
        
console_print(id"automessages is OFF.")
    }
    
console_print(id"rules_enable <1|0> (1 = ON, 0 = OFF)")
    return 
PLUGIN_HANDLED        
    
}

public 
clientrules(idlevelcid) {
    new 
pID[1]
    
pID[0] = id
    
    console_print
(0,"[user %d]Print rules for me only",pID[0])
    
printrules(pID[0])
    
    
g_sawrules[pID[0]] = true// this is to let the plugin know the player used that command (dor123)
}

public 
rules(idlevelcid)
{
    new 
pID[1]
    
pID[0] = id
            
    
if (!cmd_access(idlevelcid0)) {  // NOT ADMIN
        
return PLUGIN_HANDLED
    
}
    
    
// read file to all users
    
pID[0] = 0
    console_print
(0,"[user %d]Print rules for all",id)
    
printrules(pID[0])
    
    
// Reset scheduled task after display
    
if (get_cvar_float("rules_interval") > 0) {
        if (
task_exists(2)) {
            
change_task(2get_cvar_float("rules_interval"))
            } else {
            
set_task(get_cvar_float("rules_interval"), "rules"200""0"b")
        }
    }
    
    return 
PLUGIN_HANDLED
}

public 
player_died(){
    
    new 
victim read_data(2);
    static 
pID[1];
    
pID[0] = victim
    
    
    
if( (pID[0]) && is_user_connected(pID[0]) ){
        
        if(
g_sawrules[pID[0]])
            return 
PLUGIN_CONTINUE// if player used the /rules command he won't see the rules when he dies (dor123)
        
        
else
            
set_task(0.1"printrules"victimpID1); // otherwise he will (dor123)
        
    
}
    
    return 
PLUGIN_HANDLED;
}

public 
newRound(){
    
    static 
players[32], players_numi;
    
    
get_players(playersplayers_num"c");
    
    for(
players_num i++)
        
g_sawrules[i] = false// changes everyones' g_sawrules[] to flase on new round
        

If it doesn't work let me know.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 08-28-2008 at 08:52. Reason: Optimized
Dores is offline
Kitami
Senior Member
Join Date: Jun 2006
Location: Toronto
Old 09-19-2008 , 22:15   Re: Edit script Public Rules on Death & Join
Reply With Quote #7

Works great thanks so much
__________________
You know what I'd like to be? I mean if I had my goddamn choice, I'd just be the catcher in the rye and all.
Kitami is offline
Kitami
Senior Member
Join Date: Jun 2006
Location: Toronto
Old 09-20-2008 , 04:09   Re: Edit script Public Rules on Death & Join
Reply With Quote #8

PHP Code:
L 08/28/2008 00:52:15: [AMXXRun time error 10 (plugin "public_rules.amxx") (native "get_user_flags") - debug not enabled!
L 08/28/2008 00:52:15: [AMXXTo enable debug modeadd "debug" after the plugin name in plugins.ini (without quotes).
L 08/28/2008 01:02:15Invalid player id 200 
__________________
You know what I'd like to be? I mean if I had my goddamn choice, I'd just be the catcher in the rye and all.
Kitami is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 09-20-2008 , 05:08   Re: Edit script Public Rules on Death & Join
Reply With Quote #9

make public_rules.amxx debug in plugins.ini
__________________
xPaw is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 09-20-2008 , 12:49   Re: Edit script Public Rules on Death & Join
Reply With Quote #10

Fixed.
PHP Code:
#include <amxmodx>
#include <amxmisc>

new base[] = "rules.txt"

new inumtext[127], hudmsg[440//max hudmessage length was 439 chars (?)
new bool:g_sawrules[33]; // add by dor123 to check if used the /rules command in the current round

public plugin_init()
{
    
    
register_plugin("AMXX Public server rules""1.20""Priski")
    
    
// register command
    
    
register_concmd("rules_show""rules"ADMIN_KICK"- show rules to everybody")
    
register_concmd("rules_enable""r_enable"ADMIN_KICK"- <1|0> set automessagin on/off")
    
register_cvar("rules_admin_only""0")
    
register_cvar("rules_join""1")
    
register_cvar("rules_join_timeout""5")
    
register_cvar("rules_hudmessage_time""10")
    
register_cvar("rules_interval""600")
    
register_clcmd("say /rules""clientrules"ADMIN_ALL"- show rules")
    
register_cvar("rules_dead_only""1"); // added by dor12 3to make sure it will only show rules if player is dead
    
    
register_event("DeathMsg""player_died""a"); // dor123
    
register_event("HLTV""newRound""a""1=0""2=0"); // dor123
    
}

public 
plugin_cfg() {
    
    if (!
file_exists(base)) {
        
write_file(base"; This is the public rules file, put your rules below")
        
write_file(base"; Remember, max amount of characters is 439")
        
console_print(0"%s file not found. creating new ..."base)
    }
    
}

public 
client_authorized id ) {
    
// on join display rules
    
    
if (get_cvar_num("rules_join")) {
        new 
tmp[1]
        
tmp[0] = id
        set_task
(1.0"showrules",id,tmp,1)
        
console_print(0"[user %d] client auth!"tmp[0])
    }
    
    return 
PLUGIN_HANDLED
}

public 
showrules (pid[]) {
    new 
id pid[0]
    
    if ( 
get_user_team(id) != && get_user_team(id) != ) {
        if (
id) {
            new 
tmp[1]
            
tmp[0] = id
            set_task
(2.0"showrules",id,tmp,1)  // not yet in server
            
console_print(0"[user %d] wait for joining team ..."id)
        }
        return 
PLUGIN_HANDLED
    
}
    
    new 
tmp[1]
    
tmp[0] = id
    
    console_print
(0"[user %d] joined team : %d"idget_user_team(id))
    
console_print(0"[user %d] printing rules after %d seconds"idget_cvar_num("rules_join_timeout"))
    
    
set_task(get_cvar_float("rules_join_timeout"), "printrules"idtmp1)  // not yet in server
    
    
return PLUGIN_HANDLED
}

public 
printrules(pid[])
{
    new 
id pid[0]
    if (
file_exists(base)){
        
        
// if only dead cvar is set to 1, the player will see the rules only if he's dead (dor123)
          
if(get_cvar_num("rules_dead_only") && !is_user_alive(id)){
        
                  
console_print(0"[user] printing rules for user %d"id)
        
                  
set_hudmessage 20015000.020.2520.1get_cvar_float("rules_hudmessage_time"), 0.051.01)
                  
format(hudmsg439"")
        
                  
// read all the rules
                  
for(i=0read_file(baseitext127num); i++) {
              
                           if (
num && text[0] != ';') {
                  
                                    
// display with predefined delay
                                    
add(hudmsg,439,text)
                                    
add(hudmsg,439,"^n")
                           }
                  }
        
                  
// show hudmessages
                  
show_hudmessage(idhudmsg)
          }
    
          
// if only dead cvar is set to 1 and user is alive, command won't execute (dor123)
          
else if(get_cvar_num("rules_dead_only") && is_user_alive(id)){
        
                
client_print(idprint_chat"Can only show rules to dead players.");
                return 
PLUGIN_HANDLED;
          }
    
          else if(!
get_cvar_num("rules_dead_only")){
        
                
console_print(0"[user] printing rules for user %d"id)
        
                
set_hudmessage 20015000.020.2520.1get_cvar_float("rules_hudmessage_time"), 0.051.01)
                
format(hudmsg439"")
        
                
// read all the rules
                
for(i=0read_file(baseitext127num); i++) {
              
                           if (
num && text[0] != ';') {
                  
                                    
// display with predefined delay
                                    
add(hudmsg,439,text)
                                    
add(hudmsg,439,"^n")
                           }
                }
        
                
// show hudmessages
                
show_hudmessage(idhudmsg)
          }
        
    }
    
    return 
PLUGIN_HANDLED
}


public 
r_enable(idlevelcid)
{
    if (!
cmd_access(idlevelcid1)) {  // NOT ADMIN
        
return PLUGIN_HANDLED
    
}
    
    new 
arg[3]
    
    
read_argv(1arg2)
    new 
value str_to_num(arg)
    
    if (!
isalnum(arg[0]))
        
value = -1
    
    
if (value == 0) {
        
        if (
task_exists(2)) // close task
            
remove_task(2)    
        
        
console_print(id"You have disabled automatic messages")
        return 
PLUGIN_HANDLED
        
    
}
    if (
value == 1) {
        
// activate task, reload if already exist
        
if (task_exists(2)) {
            
change_task(2get_cvar_float("rules_interval"))
            } else {
            
set_task(get_cvar_float("rules_interval"), "rules"2""0"b")
        }    
        
console_print(id"You have enabled automatic messages")
        return 
PLUGIN_HANDLED        
    
}
    if (
task_exists(2)) {
        
console_print(id"automessages is ON.")
        } else {
        
console_print(id"automessages is OFF.")
    }
    
console_print(id"rules_enable <1|0> (1 = ON, 0 = OFF)")
    return 
PLUGIN_HANDLED        
    
}

public 
clientrules(idlevelcid) {
    new 
pID[1]
    
pID[0] = id
    
    console_print
(0,"[user %d]Print rules for me only",pID[0])
    
printrules(pID[0])
    
    
g_sawrules[pID[0]] = true// this is to let the plugin know the player used that command (dor123)
}

public 
rules(idlevelcid)
{
    new 
pID[1]
    
pID[0] = id
            
    
if (!cmd_access(idlevelcid1)) {  // NOT ADMIN
        
return PLUGIN_HANDLED
    
}
    
    
// read file to all users
    
pID[0] = 0
    console_print
(0,"[user %d]Print rules for all",id)
    
printrules(pID[0])
    
    
// Reset scheduled task after display
    
if (get_cvar_float("rules_interval") > 0) {
        if (
task_exists(2)) {
            
change_task(2get_cvar_float("rules_interval"))
            } else {
            
set_task(get_cvar_float("rules_interval"), "rules"200""0"b")
        }
    }
    
    return 
PLUGIN_HANDLED
}

public 
player_died(){
    
    new 
victim read_data(2);
    static 
pID[1];
    
pID[0] = victim
    
    
    
if( (pID[0]) && is_user_connected(pID[0]) ){
        
        if(
g_sawrules[pID[0]])
            return 
PLUGIN_CONTINUE// if player used the /rules command he won't see the rules when he dies (dor123)
        
        
else
            
set_task(0.1"printrules"victimpID1); // otherwise he will (dor123)
        
    
}
    
    return 
PLUGIN_HANDLED;
}

public 
newRound(){
    
    static 
players[32], players_numi;
    
    
get_players(playersplayers_num"c");
    
    for(
players_num i++)
        
g_sawrules[i] = false// changes everyones' g_sawrules[] to flase on new round
        

You had problems with the admin commands right? Try them now and tell me if it works OK.
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ

Last edited by Dores; 09-20-2008 at 12:58.
Dores 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 03:08.


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