Hi!
I'm having problem with my code, it's about VIP Prefix. I want that when ever VIP player sends message with prefix on (you can turn it on/off in menu for vips but that doesn't matter now) if he's alive, alive players see it, if he's dead, dead players see it if he sends in say_team only his team sees it. Like normal chat.
I tried something like this but it won't work and will crash my game with error
PHP Code:
MSG_ONE or MSG_ONE_UNRELIABLE with no target entity .
Also i am curious if my loop is good ?
Here's code what i've tried.
Spoiler
PHP Code:
new VIP_Max_Players
public plugin_init ()
{
register_clcmd ( "say" , "VIP_Prefix" )
register_clcmd ( "say_team" , "VIP_Prefix_Team" )
VIP_Max_Players = get_maxplayers ()
}
public VIP_Prefix ( id )
{
new Message [ 192 ]
new Name [ 33 ]
get_user_name ( id , Name , charsmax ( Name ))
read_args ( Message , charsmax ( Message ))
remove_quotes ( Message )
if( VIPChatPrefix [ id ])
{
if( is_user_alive ( id ))
{
ColorChat ( 0 , TEAM_COLOR , "^1[^3VIP^1] ^4%s ^1: %s" , Name , Message )
}
else
{
for(new Player = 1 ; Player <= VIP_Max_Players ; Player ++)
if(! is_user_alive ( Player ))
{
ColorChat ( Player , TEAM_COLOR , "^1*DEAD* [^3VIP^1] ^4%s ^1: %s" , Name , Message )
}
}
}
else
{
return PLUGIN_CONTINUE
}
return PLUGIN_HANDLED_MAIN
}
public VIP_Prefix_Team ( id )
{
new Message [ 192 ]
new Name [ 33 ]
get_user_name ( id , Name , charsmax ( Name ))
read_args ( Message , charsmax ( Message ))
remove_quotes ( Message )
if( VIPChatPrefix [ id ])
{
if( is_user_alive ( Player ))
{
if( cs_get_user_team ( Player ) == CS_TEAM_CT )
{
ColorChat ( Player , TEAM_COLOR , "^1(Counter-Terrorist) [^3VIP^1] ^4%s ^1: %s" , Name , Message )
}
else if( cs_get_user_team ( Player ) == CS_TEAM_T )
{
ColorChat ( Player , TEAM_COLOR , "^1(Terrorist) [^3VIP^1] ^4%s ^1: %s" , Name , Message )
}
}
else
{
if( cs_get_user_team ( Player ) == CS_TEAM_CT )
{
ColorChat ( Player , TEAM_COLOR , "^1*DEAD* (Counter-Terrorist) [^3VIP^1] ^4%s ^1: %s" , Name , Message )
}
else if( cs_get_user_team ( Player ) == CS_TEAM_T )
{
ColorChat ( Player , TEAM_COLOR , "^1*DEAD* (Terrorist) [^3VIP^1] ^4%s ^1: %s" , Name , Message )
}
}
}
else
{
return PLUGIN_CONTINUE
}
return PLUGIN_HANDLED_MAIN
}
__________________