Junior Member
|
08-01-2021
, 21:43
Different messages controlled by if statemenets
|
#1
|
Hello, Im trying to add different cvars and have them each show a different message when they are enabled.
I have 5-6 cvars(kz_nfs, kz_wayz ,icevip ,newicevip ,sxj) and i want to combine them with another cvar(kz_chatinfo) and what i want to achieve is the following:
If any of the cvars is enabled WITH kz_chatinfo ENABLED ==> Different Message for each cvar
If any of the cvars is enabled WITH kz_chatinfo DISABLED ==> Different message for each cvar
If NONE of the cvars is enabled AND kz_chatinfo is DISABLED ==> another message (Default message) when everything is disabled.
Whenever i try to use If and else if for each it just wont compile saying either invalid expressions, or expected ";" and found "if" or ")" and when it finally DOES compile, all the messages show at the same time, like the cvars arent doing or controlling anything. Im attaching the plugin and posting the code of the problem area in the post. Hopeflly someone can save me from this hell
EDIT: Just posted the full plugin files and an updated sma file. The file compiles fine now but the issue is that all the message appear at once, not when each cvar is enabled. Like even if all/most(?) of them are off, it still gives 6 different messages.
PHP Code:
if(get_pcvar_num(kz_nfs) && get_pcvar_num(kz_chatinfo))
{
ColorChat(ids, RED, "^3[%s] %s %s'd %.3f units! Strafes: %i Sync: %i%% ^1%s%s%s", prefix, g_playername[id], Jtype[id], distance[id], strafe_num[id], sync_[id], block_str, weapon_name, pre_type[id]);
}
else if (get_pcvar_num(kz_nfs))
ColorChat(ids, RED,"^3[%s] %s %s'd %.3f units! %i%% ^1%s%s%s",prefix, g_playername[id],Jtype[id],distance[id],block_str,weapon_name,pre_type[id]);
else
{
if(jump_type[id]==Type_LongJump||jump_type[id]==Type_HighJump)
ColorChat(ids, RED,"^1[%s] ^3%s jumped %.3f units! ^1%s%s%s",prefix, g_playername[id], distance[id],block_str,weapon_name,pre_type[id]);
else
ColorChat(ids, RED,"^1[%s] ^3%s jumped %.3f units with %s! ^1%s%s%s",prefix, g_playername[id], distance[id],Jtype1[id],block_str,weapon_name,pre_type[id]);
}
if(get_pcvar_num(kz_wayz) && get_pcvar_num(kz_chatinfo))
{
ColorChat(ids, RED,"^1[%s] ^4%s ^1%s Distance: ^3%.1f ^1Pre: ^3%.1f ^1Strafes: ^3%i ^1Sync: ^3%i%% %s%s%s", prefix,g_playername[id],Jtype[id],distance[id],prestrafe[id],strafe_num[id],sync_[id],block_str,weapon_name,pre_type[id]);
}
else if(get_pcvar_num(kz_wayz))
ColorChat(ids, RED,"^1[%s] ^4%s ^1%s Distance: ^3%.1f ^1Pre: ^3%.1f ^1Strafes: ^3%i ^1Sync: ^3%i%% %s%s%s", prefix,g_playername[id],Jtype[id],distance[id],prestrafe[id],strafe_num[id],sync_[id],block_str,weapon_name,pre_type[id]);
else
{
if(jump_type[id]==Type_LongJump||jump_type[id]==Type_HighJump)
ColorChat(ids, RED,"^1[%s] ^3%s jumped %.3f units! ^1%s%s%s",prefix, g_playername[id], distance[id],block_str,weapon_name,pre_type[id]);
else
ColorChat(ids, RED,"^1[%s] ^3%s jumped %.3f units with %s! ^1%s%s%s",prefix, g_playername[id], distance[id],Jtype1[id],block_str,weapon_name,pre_type[id]);
}
if(get_pcvar_num(kz_icevip) && get_pcvar_num(kz_chatinfo))
{
ColorChat(ids, RED,"^3[%s] %s jumped %.3f units with %s on %s like a BOSS! Strafes: %i Sync: %i%% ^1%s%s",prefix, g_playername[id],distance[id],Jtype[id],block_str,strafe_num[id],sync_[id],weapon_name,pre_type[id]);
}
else if(get_pcvar_num(kz_icevip))
ColorChat(ids, RED,"^3[%s] %s jumped %.3f units with %s on %s like a BOSS! ^1%s%s",prefix, g_playername[id],distance[id],Jtype[id],block_str,weapon_name,pre_type[id]);
else
{
if(jump_type[id]==Type_LongJump||jump_type[id]==Type_HighJump)
ColorChat(ids, RED,"^1[%s] ^3%s jumped %.3f units! ^1%s%s%s",prefix, g_playername[id], distance[id],block_str,weapon_name,pre_type[id]);
else
ColorChat(ids, RED,"^1[%s] ^3%s jumped %.3f units with %s! ^1%s%s%s",prefix, g_playername[id], distance[id],Jtype1[id],block_str,weapon_name,pre_type[id]);
}
if(get_pcvar_num(kz_nfsicevip) && get_pcvar_num(kz_chatinfo))
{
ColorChat(ids, RED,"^3[%s] %s %s'd %.3f units on %s like a BOSS! Strafes: %i Sync: %i%% ^1%s%s",prefix, g_playername[id],Jtype[id],distance[id],block_str,strafe_num[id],sync_[id],weapon_name,pre_type[id]);
}
else if(get_pcvar_num(kz_nfsicevip))
ColorChat(ids, RED,"^3[%s] %s %s'd %.3f units on %s like a BOSS! Strafes: %i Sync: %i%% ^1%s%s",prefix, g_playername[id],Jtype[id],distance[id],block_str,strafe_num[id],sync_[id],weapon_name,pre_type[id]);
else
{
if(jump_type[id]==Type_LongJump||jump_type[id]==Type_HighJump)
ColorChat(ids, RED,"^1[%s] ^3%s jumped %.3f units! ^1%s%s%s",prefix, g_playername[id], distance[id],block_str,weapon_name,pre_type[id]);
else
ColorChat(ids, RED,"^1[%s] ^3%s jumped %.3f units with %s! ^1%s%s%s",prefix, g_playername[id], distance[id],Jtype1[id],block_str,weapon_name,pre_type[id]);
}
if(get_pcvar_num(kz_newicevip) && get_pcvar_num(kz_chatinfo))
{
ColorChat(ids, RED,"^1[%s] ^3%s jumped %.3f units %s with %i strafes and %i%% sync on %s like a BOSS! ^1%s%s",prefix, g_playername[id], distance[id],Jtype[id],strafe_num[id],sync_[id],block_str,weapon_name,pre_type[id]);
}
else if(get_pcvar_num(kz_newicevip))
ColorChat(ids, RED,"^1[%s] ^3%s jumped %.3f units %s on %s like a BOSS! ^1%s%s",prefix, g_playername[id], distance[id],Jtype[id],block_str,weapon_name,pre_type[id]);
else
{
if(jump_type[id]==Type_LongJump||jump_type[id]==Type_HighJump)
ColorChat(ids, RED,"^1[%s] ^3%s jumped %.3f units! ^1%s%s%s",prefix, g_playername[id], distance[id],block_str,weapon_name,pre_type[id]);
else
ColorChat(ids, RED,"^1[%s] ^3%s jumped %.3f units with %s! ^1%s%s%s",prefix, g_playername[id], distance[id],Jtype1[id],block_str,weapon_name,pre_type[id]);
}
if(get_pcvar_num(kz_sxj) && get_pcvar_num(kz_chatinfo) && jump_type[id] == Type_LongJump || jump_type[id] == Type_HighJump)
{
ColorChat(ids, RED, "^1[%s] ^3%s jumped %.3f units! Strafes: %i Sync: %i%% ^1%s%s%s", prefix, g_playername[id], distance[id], strafe_num[id], sync_[id], block_str, weapon_name, pre_type[id]);
}
else if(get_pcvar_num(kz_sxj))
ColorChat(ids, RED, "^1[%s] ^3%s jumped %.3f units! ^1%s%s%s", prefix, g_playername[id], distance[id], block_str, weapon_name, pre_type[id]);
else
{
if(jump_type[id]==Type_LongJump||jump_type[id]==Type_HighJump)
ColorChat(ids, RED,"^1[%s] ^3%s jumped %.3f units! ^1%s%s%s",prefix, g_playername[id], distance[id],block_str,weapon_name,pre_type[id]);
else
ColorChat(ids, RED,"^1[%s] ^3%s jumped %.3f units with %s! ^1%s%s%s",prefix, g_playername[id], distance[id],Jtype1[id],block_str,weapon_name,pre_type[id]);
}
}
Last edited by staNioN; 08-02-2021 at 06:45.
Reason: Uploaded new .sma file and all the necessary plugin stuff
|
|