Little help
#1

Hey SA-MP, I have problem, one command which have problem, it`s passing few if`s, then it`s not working, here it is, please check the code there is no errors...

pawn Код:
ADMCMD:teleteam(playerid, params[], 3)
{
    new team, Float:x, Float:y, Float:z;
    if(sscanf(params, "d", team)) return SendServer(playerid, "/teleteam [team ID]");
    if(team < 0 || team > 3) return SendError(playerid, "Invalid team ID !");
    GetPlayerPos(playerid, x, y, z);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(GetPlayerTeam(i) == team)
        {
            SetPlayerPos(i, x, y, z);
        }
        return 1;
    }
   
    if(pInfo[playerid][pHide] == 0)
    {
        SendMessageToAll(-1, ""embed_orange"[Admin] "embed_white"Administrator %s has teleported "embed_grey"Team %d"embed_white" to himself!", pName[playerid], team);

        SendMessage(playerid, -1, ""embed_orange"[Admin] "embed_white"You have teleported "embed_grey"Team %d"embed_white" to yourself!", team);
    }
    else
    {
        SendMessageToAll(-1, ""embed_orange"[Admin] "embed_white"Administrator has teleported "embed_grey"Team %d"embed_white" to himself!", pName[playerid], team);

        SendMessage(playerid, -1, ""embed_orange"[Admin] "embed_white"You have teleported "embed_grey"Team %d"embed_white" to yourself!", team);
    }
    return 1;
}
Reply
#2

What's not working? You don't need that return 1 in the loop. Also if you are using 0.3.7 consider changing your loop.

Код:
// Old code
for(new x=0; x < MAX_PLAYERS; x++) {
    if(IsPlayerConnected(x)) { // do stuff with a player id
    }
}

// New code
new HighestPlayerId = GetPlayerPoolSize();
for(new x=0; x <= HighestPlayerId; x++) { // (note the condition change from < to <=)
    if(IsPlayerConnected(x)) { // do stuff with a player id
    }
}
More information in the original topic: https://sampforum.blast.hk/showthread.php?tid=559572
Reply
#3

-Delete-
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)