SA-MP Forums Archive
How to do this! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to do this! (/showthread.php?tid=285234)



How to do this! - [MKD]Max - 23.09.2011

Hello all please how i can when player do /joingroup

and use then /pmg to talk

only who in InGroup can see!



Код:
	if(strcmp(cmd, "/joingroup", true) == 0)
	{
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) {
    SendClientMessage(playerid, COLOR_ERROR, "USAGE: /joingroup (id)");
    return 1;
    }
    if(!IsNumeric(tmp)) {
    SendClientMessage(playerid, COLOR_ERROR, "USAGE: /joingroup (id) ID Must be a number");
    return 1;
    }
    giveplayerid = strval(tmp);
    if(InGroup[playerid] == 1){
    SendClientMessage(playerid,COLOR_ERROR,"You are already in group!");
    return 1;
    }
    if(GroupInvit[giveplayerid] == 0){
    format(string,sizeof(string),"You are not invited to Group (ID:%d)",giveplayerid);
    return 1;
    }
    if(GroupOwner[giveplayerid] == 0){
    format(string,sizeof(string),"This player is dont have his own group!");
    return 1;
    }
    new pname[24];
    new oname[24];
	GetPlayerName(playerid,pname,24);
	GetPlayerName(giveplayerid,oname,24);
    for(new i=0;i<MAX_PLAYERS;i++){
   	if(InGroup[i] == 1 && i != playerid){
	format(string,sizeof(string),"%s(%d) Has Joined Pming Group",pname,playerid);
	SendClientMessage(i,COLOR_GREEN,string);
	format(string,sizeof(string),"You have joing Pming Group (ID:%d)",giveplayerid);
	SendClientMessage(playerid,COLOR_GREEN,string);
	InGroup[playerid] =1;
	GroupInvit[playerid] =0;
	}
	}
	return 1;
	}



Re: How to do this! - Lorenc_ - 23.09.2011

pawn Код:
stock SendClientMessageToGroup(playerid, col, msg[])
{
    for(new i; i != MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(playerid)) break;
        if(!IsPlayerConnected(i)) continue;
        if(InGroup[playerid] != InGroup[i]) continue;
        SendClientMessage(i, col, msg);
        continue;
    }
}

CMD:pmg(playerid, params[])
{
    new
        text[256], // I'm going to suit your roleplay scripts efficiency! >:D
        string[256],
        name[50]
    ;
    GetPlayerName(playerid, name, 24);
    if(InGroup[playerid] <= 0) return Ban(playerid);
    else if(sscanf(params, "s[64]", text)) Ban(playerid);
    else
    {
        format(string, sizeof(string), "<Group> %s(%d) says: %s", name, playerid, text);
        SendClientMessageToGroup(playerid, -1, text);
    }
    return 1;
}
Try this, I'm using ZCMD, sscanf and roleplay cell sizes!

(untested)