TeamChat on setteam
#1

how to make team chat on setteam ?
example , i`m /setteam 1 , and teamchat can showing for player on /setteam 1
how to make it on 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(" Running FilterScript Leingod's team chooser v"#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;
}

COMMAND:teamhelp(playerid, params[])
{
    #pragma unused params
    SendClientMessage(playerid, usage, "Team Set Helps:");
    SendClientMessage(playerid, lancar, "/setteam = for selecting teams with the numbered id");
    SendClientMessage(playerid, lancar, "/myteam = for see your team id");
    SendClientMessage(playerid, lancar, "/resetteam = for setting your team to netral");
    SendClientMessage(playerid, error, "TeamChooser credits: leingod the creator of this command");
    return 1;
}
Sorry for bad english
Reply
#2

Try This:

pawn Код:
COMMAND:teamchat(playerid,params[]){
new text[128],pn[MAX_PLAYER_NAME],m[128];
GetPlayerName(playerid,pn,sizeof(pn));
if(sscanf(params,"s[128]",text)) return SendClientMessage(playerid,0xFFFFFFFF,"Correct Usage: /teamchat [message]");
format(m,sizeof(m),"[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 1;
}
Reply
#3

Quote:
Originally Posted by jtemple042996
Посмотреть сообщение
Try This:

pawn Код:
COMMAND:teamchat(playerid,params[]){
new text[128],pn[MAX_PLAYER_NAME],m[128];
GetPlayerName(playerid,pn,sizeof(pn));
if(sscanf(params,"s[128]",text)) return SendClientMessage(playerid,0xFFFFFFFF,"Correct Usage: /teamchat [message]");
format(m,sizeof(m),"[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 1;
}
thanks working , but how to change to "@" so just @ [text] , no need /teamchat
thanks before
Reply
#4

Here you go:
pawn Код:
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),"[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
#5

Wow thanks .
Rep ++ given
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)