Raised This Month: $51 Target: $400
 12% 

[HELP]My Chat System Error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ryo89589
Member
Join Date: Aug 2011
Old 10-11-2012 , 06:53   [HELP]My Chat System Error
Reply With Quote #1

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()

ryo89589 is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 10-11-2012 , 10:11   Re: [HELP]My Chat System Error
Reply With Quote #2

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.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
ryo89589
Member
Join Date: Aug 2011
Old 10-11-2012 , 10:41   Re: [HELP]My Chat System Error
Reply With Quote #3

Quote:
Originally Posted by Liverwiz View Post
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.
ryo89589 is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 10-13-2012 , 09:21   Re: [HELP]My Chat System Error
Reply With Quote #4

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.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz 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 06:40.


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