Command /Find
#1

Hello every one i am making Zombie Server and i wanna make Class for zombie that Can /find and Teleport to the Closest Player i got everything but ,Zombie won't Teleport to the Human
Here is the Code
pawn Код:
COMMAND:find(playerid, params[])
        {
        new targetid,Float:x,Float:y,Float:z;
        if(gTeam[playerid] == TEAM_ZOMBIES && ZombieClass[playerid] == Rotting)
        {
      for(new i = 0; i < MAX_PLAYERS; i++)
            if(!IsPlayerConnected(i) && gTeam[i] == TEAM_ZOMBIES)
                {
                return SendClientMessage(playerid,COLOR_RED,"No humans Online");
                }
        if(gTeam[targetid] == TEAM_HUMANS)
        {
        targetid = GetClosestPlayer(playerid);
        GetPlayerPos(targetid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        }
        }
        else return SendClientMessage(playerid,COLOR_RED,"You are Not Rotting/Zombie");
        return 1;
        }
Reply
#2

pawn Код:
COMMAND:find(playerid, params[])
        {
        new targetid,Float:x,Float:y,Float:z;
        if(gTeam[playerid] == TEAM_ZOMBIES && ZombieClass[playerid] == Rotting)
        {
      for(new i = 0; i < MAX_PLAYERS; i++)
            if(!IsPlayerConnected(i) && gTeam[i] == TEAM_ZOMBIES)
                {
                return SendClientMessage(playerid,COLOR_RED,"No humans Online");
                }
        if(gTeam[targetid] == TEAM_HUMANS)
        {
        targetid = GetClosestPlayer(playerid);
        GetPlayerPos(targetid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        }
        }
        else return SendClientMessage(playerid,COLOR_RED,"You are Not Rotting/Zombie");
        }
Reply
#3

Quote:
Originally Posted by Xtreme_playa
Посмотреть сообщение
pawn Код:
COMMAND:find(playerid, params[])
        {
        new targetid,Float:x,Float:y,Float:z;
        if(gTeam[playerid] == TEAM_ZOMBIES && ZombieClass[playerid] == Rotting)
        {
      for(new i = 0; i < MAX_PLAYERS; i++)
            if(!IsPlayerConnected(i) && gTeam[i] == TEAM_ZOMBIES)
                {
                return SendClientMessage(playerid,COLOR_RED,"No humans Online");
                }
        if(gTeam[targetid] == TEAM_HUMANS)
        {
        targetid = GetClosestPlayer(playerid);
        GetPlayerPos(targetid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        }
        }
        else return SendClientMessage(playerid,COLOR_RED,"You are Not Rotting/Zombie");
        }
Lol Nothing Change just 1 warning xD
Reply
#4

Quote:
Originally Posted by [D]ry[D]esert
Посмотреть сообщение
Lol Nothing Change just 1 warning xD
And what's that ? Btw in your command you had an extra return in the end, while you already returned the value with else statement, which i removed in my post.
Reply
#5

Quote:
Originally Posted by Xtreme_playa
Посмотреть сообщение
And what's that ? Btw in your command you had an extra return in the end, while you already returned the value with else statement, which i removed in my post.
Nah it was't extra its the main one
don't forget i made else return not just return
Reply
#6

Quote:
Originally Posted by [D]ry[D]esert
Посмотреть сообщение
Nah it was't extra its the main one
don't forget i made else return not just return
There cannot be two returns at the end if you're using else statement, that else return would be the main return.
Reply
#7

PHP код:
COMMAND:find(playeridparams[])
        {
        new 
targetid,Float:x,Float:y,Float:zstring[60];
        if(
gTeam[playerid] == TEAM_ZOMBIES && ZombieClass[playerid] == Rotting)
        {
        for(new 
0MAX_PLAYERSi++)
        {
        if(!
IsPlayerConnected(i) || gTeam[i] == TEAM_ZOMBIES) return SendClientMessage(playerid,"No humans online");
        }
        
targetid GetClosestPlayer(playerid);
        
GetPlayerPos(targetid,x,y,z);
        
SetPlayerPos(playerid,x,y,z);
        
format(string,sizeof(string),"Teleported to %s",GetPlayerName(targetid));
        
SendClientMessage(playerid,COLOR_RED,string);
        return 
1;
        }
        if(
gTeam[playerid] == TEAM_HUMANS)
        {
        for(new 
0MAX_PLAYERSi++)
        {
        if(!
IsPlayerConnected(i) || gTeam[i] == TEAM_HUMANS) return SendClientMessage(playerid,"No zombies online");
        }
        
targetid GetClosestPlayer(playerid);
        
GetPlayerPos(targetid,x,y,z);
        
SetPlayerPos(playerid,x,y,z);
        
format(string,sizeof(string),"Teleported to %s",GetPlayerName(targetid));
        
SendCLientMessage(playerid,COLOR_RED,string);
        }
        } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)