AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP]My Chat System Error (https://forums.alliedmods.net/showthread.php?t=198071)

ryo89589 10-11-2012 06:53

[HELP]My Chat System Error
 
See me First:
When I use **Super** and say "test"
System say:
Code:

<Survive>【OP】**Super** : test
<Survive>【Admin】**Super** : test

Why it say again? How to solve?

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#define PLUGIN_NAME "Chat System"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "ryo89589"
public plugin_init(){
 
register_plugin(PLUGIN_NAME,PLUGIN_VERSION,PLUGIN_AUTHOR)
 
register_clcmd("say","sign_say",ADMIN_ALL,"- Colored Sign Chat")
}
public 
sign_say(id){
 
 new 
text[64],name[32],message[128]
 
read_args (text,63)
 
remove_quotes(text)
 
get_user_name(id,name,31)
 for(new 
0<= get_maxplayers(); i++) {
  
get_user_name(iname31)
  if(
is_user_alive(i) && equali(name"**Super**")){
   if(
is_user_alive(id))
   { 
   
format(message,127,"^x01<Survive>^x04【OP】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
   if(!
is_user_alive(id) && cs_get_user_team(id) != CS_TEAM_SPECTATOR && cs_get_user_team(id) != CS_TEAM_UNASSIGNED)
   {
   
format(message,127,"^x01<Died>^x04【OP】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
    else if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED)
   {
   
format(message,127,"^x01<Spectator>^x04【OP】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
  }
  else if(
is_user_alive(i) && equali(name"**Way**")){
   if(
is_user_alive(id))
   { 
   
format(message,127,"^x01<Survive>^x04【Super Admin】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
   if(!
is_user_alive(id) && cs_get_user_team(id) != CS_TEAM_SPECTATOR && cs_get_user_team(id) != CS_TEAM_UNASSIGNED)
   {
   
format(message,127,"^x01<Died>^x04【Super Admin】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
    else if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED)
   {
   
format(message,127,"^x01<Spectator>^x04【Super Admin】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
  }
 }
 if ((
get_user_flags(id) & ADMIN_MENU)){
   if(
is_user_alive(id))
   { 
   
format(message,127,"^x01<Survive>^x04【Admin】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
   if(!
is_user_alive(id) && cs_get_user_team(id) != CS_TEAM_SPECTATOR && cs_get_user_team(id) != CS_TEAM_UNASSIGNED)
   {
   
format(message,127,"^x01<Died>^x04【Admin】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
    else if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED)
   {
   
format(message,127,"^x01<Spectator>^x04【Super Admin】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
  }
 else if ((
get_user_flags(id) & ADMIN_BAN)){
   if(
is_user_alive(id))
   { 
   
format(message,127,"^x01<Survive>^x04【VIP】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
   if(!
is_user_alive(id) && cs_get_user_team(id) != CS_TEAM_SPECTATOR && cs_get_user_team(id) != CS_TEAM_UNASSIGNED)
   {
   
format(message,127,"^x01<Died>^x04【VIP】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
    else if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED)
   {
   
format(message,127,"^x01<Spectator>^x04【VIP】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
  }
 else {
   if(
is_user_alive(id))
   { 
   
format(message,127,"^x01<Survive>^x04【Player】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
   if(!
is_user_alive(id) && cs_get_user_team(id) != CS_TEAM_SPECTATOR && cs_get_user_team(id) != CS_TEAM_UNASSIGNED)
   {
   
format(message,127,"^x01<Died>^x04【Player】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
    else if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED)
   {
   
format(message,127,"^x01<Spectator>^x04【Player】^x03%s^x01 : %s",name,text)
   
client_color(0,id,message)
   }
  }
 
server_print("%s : %s"namemessage)
 return 
PLUGIN_HANDLED
}
public 
client_color(playeridcoloridmsg[]){
 
message_begin(playerid?MSG_ONE:MSG_ALL,get_user_msgid("SayText"),{0,0,0},playerid
 
write_byte(colorid)
 
write_string(msg)
 
message_end()



Liverwiz 10-11-2012 10:11

Re: [HELP]My Chat System Error
 
Code:

for(new i = 0; i <= get_maxplayers(); i++) {
  get_user_name(i, name, 31)

There is no player id of 0. This will throw an error. This is also horrendous. Use get_players

By the way you're checking things in your if statements....you're checking a lot of things twice. This is ugly and inefficient.

If you don't want it to print another thing, just return out of the function once you've printed, your code is written to continue execution, so your output is correct.

I'd say just start from scratch. This is really, really bad code that could be redesigned to work much better.

ryo89589 10-11-2012 10:41

Re: [HELP]My Chat System Error
 
Quote:

Originally Posted by Liverwiz (Post 1816825)
Code:

for(new i = 0; i <= get_maxplayers(); i++) {
  get_user_name(i, name, 31)

There is no player id of 0. This will throw an error. This is also horrendous. Use get_players

By the way you're checking things in your if statements....you're checking a lot of things twice. This is ugly and inefficient.

If you don't want it to print another thing, just return out of the function once you've printed, your code is written to continue execution, so your output is correct.

I'd say just start from scratch. This is really, really bad code that could be redesigned to work much better.

How to correction?I don't know to correction.Thank you.

Liverwiz 10-13-2012 09:21

Re: [HELP]My Chat System Error
 
Just give it a shot and post your code. Try again, starting from scratch. You won't learn any other way.

If you're looking for more guidance go read some other people's code in the approved section.


All times are GMT -4. The time now is 07:09.

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