AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Whats is better? (https://forums.alliedmods.net/showthread.php?t=153519)

^SmileY 03-24-2011 21:39

Whats is better?
 
Please, explain what is better script (Remember: the plugins have the same function).

cvar: pug_warmup is created by other plugin

PHP Code:

public CHECAR()
{
get_players(USERS,TRs,"e","TERRORIST")
get_players(USERS,CTs,"e","CT")
TOTAL get_playersnum()

new 
WARMUP get_cvar_num("pug_warmup")

if(
WARMUP == 1)
return 
PLUGIN_HANDLED

else if(WARMUP == && TOTAL <= MINIMOGH)
{
client_print(0,3,"%s Faltam %d jogadores para continuar. (Reiniciando em %d segundos)",HEADER,(10 TOTAL),TEMPO)
set_task(float(TEMPO),"RESTART")
return 
PLUGIN_HANDLED
}
else if(
WARMUP == && TRs <= MINIMO)
{
client_print(0,3,"%s Reiniciando sistema em %d segundos. (Faltando: %d TRs - %d CTs)",HEADER,TEMPO,(TRs),(CTs))
set_task(float(TEMPO),"RESTART")
return 
PLUGIN_HANDLED
}
else if(
WARMUP == && CTs <= MINIMO)
{
client_print(0,3,"%s Reiniciando sistema em %d segundos. (Faltando: %d TRs - %d CTs)",HEADER,TEMPO,(TRs),(CTs))
set_task(float(TEMPO),"RESTART")
return 
PLUGIN_HANDLED
}
return 
PLUGIN_HANDLED


Or:

PHP Code:

public CHECAR()
{
get_players(USERS,TRs,"e","TERRORIST")
get_players(USERS,CTs,"e","CT")
TOTAL get_playersnum()

new 
WARMUP get_cvar_num("pug_warmup")

switch(
WARMUP)
{
case 
0:
{
if(
TRs <= MINIMO)
{
client_print(0,3,"%s Reiniciando sistema em %d segundos. (Faltando: %d TRs - %d CTs)",HEADER,TEMPO,(TRs),(CTs))
set_task(float(TEMPO),"RESTART")
return 
PLUGIN_HANDLED
}
else if(
CTs <= MINIMO)
{
client_print(0,3,"%s Reiniciando sistema em %d segundos. (Faltando: %d TRs - %d CTs)",HEADER,TEMPO,(TRs),(CTs))
set_task(float(TEMPO),"RESTART")
return 
PLUGIN_HANDLED
}
}
case 
1:
{
return 
PLUGIN_HANDLED
}
case 
2:
{
if(
TOTAL <= MINIMOGH)
{
client_print(0,3,"%s Faltam %d jogadores para continuar. (Reiniciando em %d segundos)",HEADER,(10 TOTAL),TEMPO)
set_task(float(TEMPO),"RESTART")
return 
PLUGIN_HANDLED
}
}
}
return 
PLUGIN_HANDLED


Ps. If it is not no, explain more :)
The beginning of the code:

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>

#define HEADER "[PUG]"

new USERS[32],TRs,CTs,TOTAL
new MINIMO 3
new MINIMOGH 5
new TEMPO 10

public plugin_init()
{
register_plugin("Minplayers",AMXX_VERSION_STR ,"SmileY")
register_logevent("CHECAR",2,"1=Round_Start")
}

public 
RESTART()
{
server_cmd("pug_votemap_enabled 1")
     
set_cvar_num("pug_votemap",1)
      
server_cmd("restart")



Exolent[jNr] 03-24-2011 21:52

Re: Whats is better?
 
The 2nd because it only checks WARMUP once when it is 0.
Also, switch statements should be used when checking a variable for multiple values.

^SmileY 03-24-2011 22:06

Re: Whats is better?
 
Quote:

Originally Posted by Exolent[jNr] (Post 1438929)
The 2nd because it only checks WARMUP once when it is 0.
Also, switch statements should be used when checking a variable for multiple values.

:bacon!: thanks

ConnorMcLeod 03-25-2011 03:01

Re: Whats is better?
 
Restored your original post and lock so you can trash it anymore.
If you don't want the code to be public don't ask help on public forum thanks.


All times are GMT -4. The time now is 14:34.

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