Player On Setteam
#1

How to create cmd /Teaminfo , with function for check player on same /setteam
example : Player "Horrible" /setteam 20 , and my friends "Kenzo" same /setteam with me , and when i type /teaminfo ,
it can showing player name in same /setteam .

In This Script :
pawn Код:
#include <a_samp>
#include <zcmd>
#include <dini>
#include <sscanf>

// COLORS
#define usage 0xFFEEC1AA
#define error 0xFF3434AA
#define lancar 0x34C6FFAA

// DEFINES
#define version_team_chooser        "1.0"

enum LData
{
    Team
};

new TeamInfo[MAX_PLAYERS][LData];
new LGDTeam[MAX_PLAYERS];


public OnFilterScriptInit()
{
    print("\n----------------------------------------------------");
    print(" Team Chooser from leingod"#version_team_chooser"");
    print("----------------------------------------------------\n");
    return 1;
}

public OnPlayerConnect(playerid)
{
    new LName[MAX_PLAYER_NAME], file[128];
    GetPlayerName(playerid,LName,sizeof(LName));
    format(file,sizeof(file),"Teams/%s.ini",LName);
    if(!dini_Exists(file))
    {
        dini_Create(file);
        dini_IntSet(file,"Team",TeamInfo[playerid][Team]);
        new rteam = random(-999999999999);
        LGDTeam[playerid] = rteam;
    }
    if(dini_Exists(file))
    {
        TeamInfo[playerid][Team] = dini_Int(file,"Team");
        LGDTeam[playerid] = dini_Int(file,"Team");
    }
    return 1;
}


// ZCMD COMMANDS
COMMAND:setteam(playerid, params[])
{
    new LTeam;
    #pragma unused params
    if(sscanf(params, "d", LTeam)) return SendClientMessage(playerid, usage, "[USAGE]: /setteam [1-999,999]");
    else if (LTeam >= 999999 || LTeam == 0) return SendClientMessage(playerid, error, "[ERROR]: Team id must between 1 and 999,999");
    else
    {
        new string[128], LName[MAX_PLAYER_NAME], file[128];
        format(string, sizeof(string), "[SERVER]: Success choosing team id -> '%d'.", LTeam);
        SendClientMessage(playerid, lancar, string);
        LGDTeam[playerid] = LTeam;
        SetPlayerTeam(playerid, LGDTeam[playerid]);
        SetPlayerTeam(playerid, LTeam);
        GetPlayerName(playerid,LName,sizeof(LName));
        format(file,sizeof(file),"Teams/%s.ini",LName);
        dini_IntSet(file,"Team",LGDTeam[playerid]);
    }
    return 1;
}

COMMAND:myteam(playerid, params[])
{
    new str[256];
    #pragma unused params
    format(str, sizeof(str), "[SERVER]: Your team id -> '%d'.", LGDTeam);
    SendClientMessage(playerid, lancar, str);
    return 1;
}

COMMAND:resetteam(playerid, params[])
{
    new rteam = random(-999999999999), LName[MAX_PLAYER_NAME], file[128];
    #pragma unused params
    LGDTeam[playerid] = rteam;
    SetPlayerTeam(playerid, LGDTeam[playerid]);
    SendClientMessage(playerid, usage, "[SERVER]: Success make your team to netral, Everybody are enemy!.");
    GetPlayerName(playerid,LName,sizeof(LName));
    format(file,sizeof(file),"Teams/%s.ini",LName);
    dini_IntSet(file,"Team",LGDTeam[playerid]);
    return 1;
}

public OnPlayerText(playerid, text[])
{
    if(text[0] == '!'){
    new pn[MAX_PLAYER_NAME],m[128];
    GetPlayerName(playerid,pn,sizeof(pn));
    strdel(text,0,1);
    format(m,sizeof(m),"{00FFFF}[TEAMCHAT] %s [%i]: %s",pn,playerid,text);
    for(new i = 0; i < MAX_PLAYERS; i++){
    if(IsPlayerConnected(i)){
    if(LGDTeam[i] == LGDTeam[playerid]){
    SendClientMessage(i,0xFFFFFFFF,m);
    }
    }
    }
    return 0;
    }
    else return 1;
}
Reply
#2

anyone help me please
Reply
#3

You can create a loop which goes through all people and only prints text for the ones who are on the same team as yours. Shouldn't be hard? Considering you did something very similar already with the team-chat.

Also, I don't think negative numbers work with the random function. If you want to reset their team, just set it to 0 or NO_TEAM.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)