Cb Channel help
#1

Hello

Can anyone help me with this filterscript i downloaded just 30mins ago

Help

- Can anyone help me when you join a channel it automatically know that u are in a channel and u don't have to type /cb to talk in it
- Can anyone help me with like when someone tries to join a channel it says an error in the chat e.g. This is for admins only

Код:
#include <a_samp>

new pChannel[MAX_PLAYERS];

#define COLOUR_RED 0xFF0000FF
#define COLOUR_YELLOW 0xFFFF00FF

#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

public OnPlayerDisconnect(playerid, reason)
{
	#pragma unused reason
	pChannel[playerid] = 0;
	return 1;
}

public OnPlayerSpawn(playerid)
{
	pChannel[playerid] = 1;
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	dcmd(cbchannel, 9, cmdtext);
	dcmd(cb, 2, cmdtext);
	return 0;
}

dcmd_cbchannel(playerid, params[])
{
    if(!strlen(params) /*&& !IsNumeric(params)*/) return SendClientMessage(playerid, COLOUR_RED, "No parameters (Usage: /cbchannel [1-40]");
    //If the length of params is 0 (non existent) - it returns an error message
    //I have commeneted our "IsNumeric" because I am not supplying it with the tutorial (because I can't find it!)
    if(strval(params) < 1 || strval(params) > 40) return SendClientMessage(playerid, COLOUR_RED, "Only channels 1 upto 40 exist");
    //If the integer value of the parameters string is lower than 1 or bigger than 40 then it returns another error message
    pChannel[playerid] = strval(params);
    //Set the players channel
        //You may also want to add a "Your channel is now %i" message.
    return 1;
    //Return 1 (command complete)
}

dcmd_cb(playerid, params[])
{
    if(!strlen(params)) return SendClientMessage(playerid, COLOUR_RED, "No parameters (Usage: /cb [message]");
    //Error message if the player did not specify any parameters
    static str[128];
    //Why static? It stops it being created more than once (in fact if you decompiled an AMX script you would find the "static" variable has become GLOBAL)
    format(str, sizeof(str), "[CB]%s: %s", ReturnName(playerid), params);
    //Format the output message (str)
    //ReturnName, is a function to return a players name - I will include it toward the end of this post
    //You could use colour embedding here!
    for(new i; i < GetMaxPlayers(); i++)
    {
        //Start the loop (GetMaxPlayers will return the MAXIMUM player slots on your server - you could use Foreach here instead)
        if(!IsPlayerConnected(i)) continue;
        //If the player is not connected, skip to the next one
        if(pChannel[i] == pChannel[playerid])
        {
            //If the player channel matches the other players channel
            SendClientMessage(i, COLOUR_YELLOW, str);
        }
    }
    return 1;
    //End the command (return 1)
}

stock ReturnName(playerid)
{
	static name[24];
	GetPlayerName(playerid, name, 24);
	return name;
}
Thanks
Reply
#2

anyone
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)