An Admin CMD that affect a team
#1

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.
Reply
#2

What variable do you use to see/place if someone is in a team?
Reply
#3

sorry about that :P

I use:

gTeam[playerid] = TEAM_INDIA;
Reply
#4

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?
Reply
#5

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.
Reply
#6

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.
Reply
#7

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
Reply
#8

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.
Reply
#9

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
Reply
#10

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)