An Admin CMD that affect a team -
megamind2067 - 05.02.2013
Hi, I', using LuxAdmin and I am attempting to make a CMD that lvl 4 admins can use and it freezes team India.
pawno code:
Код:
dcmd_freezeindia(playerid,params[])
{
#pragma unused params
if(AccInfo[playerid][Level] >= 4)
{
{
}
return 1;
}
Can someone please teach me how to. thanks.
Re: An Admin CMD that affect a team -
vIBIENNYx - 05.02.2013
What variable do you use to see/place if someone is in a team?
Re: An Admin CMD that affect a team -
megamind2067 - 05.02.2013
sorry about that :P
I use:
gTeam[playerid] = TEAM_INDIA;
Re: An Admin CMD that affect a team -
vIBIENNYx - 05.02.2013
Okay, so..
You can use a "Loop" to go through every array or "playerid" in the varibale "gTeam" and check if they match TEAM_INDIA. You can do this like:
pawn Код:
for(new i; i<MAX_PLAYERS; i++)
{
if(gTeam[i] == TEAM_INDIA)
{
// DO SOMETHING
}
}
What this does is it checks every player to see if they are in TEAM_INDIA. If they are then you can do what you want. If not it will continue to the next player. The reason we use "==" instead of "=" is because "=" is an assignment.
Do you follow?
Re: An Admin CMD that affect a team -
iGetty - 05.02.2013
Quote:
Originally Posted by vIBIENNYx
Okay, so..
You can use a "Loop" to go through every array or "playerid" in the varibale "gTeam" and check if they match TEAM_INDIA. You can do this like:
pawn Код:
for(new i; i<MAX_PLAYERS; i++) { if(gTeam[i] == TEAM_INDIA) { // DO SOMETHING } }
What this does is it checks every player to see if they are in TEAM_INDIA. If they are then you can do what you want. If not it will continue to the next player. The reason we use "==" instead of "=" is because "=" is an assignment.
Do you follow?
|
Karner, make sure you use if(IsPlayerConnected(i)), it seems to work a lot quicker for me when I add that 1 single thing.
Re: An Admin CMD that affect a team -
vIBIENNYx - 05.02.2013
Quote:
Originally Posted by iGetty
Karner, make sure you use if(IsPlayerConnected(i)), it seems to work a lot quicker for me when I add that 1 single thing.
|
Actually, it won't. It's a waste of CPU.
Re: An Admin CMD that affect a team -
iGetty - 05.02.2013
Quote:
Originally Posted by vIBIENNYx
Actually, it won't. It's a waste of CPU.
|
Seems to always make mine run a lot quicker and doesn't cause any lag/noticeable CPU usage. :P
Re: An Admin CMD that affect a team -
vIBIENNYx - 05.02.2013
Quote:
Originally Posted by iGetty
Seems to always make mine run a lot quicker and doesn't cause any lag/noticeable CPU usage. :P
|
With loops that check multiple variables, yes that would be better. Seeing as we're only checking one variable there is no need for the extra function or CPU usage to continue through the loop.
Re: An Admin CMD that affect a team -
megamind2067 - 05.02.2013
Ok thanks but I hope what happened last time won't happen again. Last Time: to use the cmd it would check for the team (india) and check if the player is lvl4 and then the player would freeze :P
Re: An Admin CMD that affect a team -
vIBIENNYx - 05.02.2013
Quote:
Originally Posted by megamind2067
Ok thanks but I hope what happened last time won't happen again. Last Time: to use the cmd it would check for the team (india) and check if the player is lvl4 and then the player would freeze :P
|
Pardon?