Making cb channel for 1 class on spawn
#1

How to make it tho when a player joins say trucker class it Sets there channel to channel. police - channel 2 etc
And also it tells the player what channel they are on.

All help appreciated.

classes are defined like
pawn Код:
// Define classes
#define ClassTruckDriver 1
#define ClassBusDriver 2
#define ClassPilot 3
#define ClassPolice 4
#define ClassMafia 5
#define ClassCourier 6
#define ClassAssistance 7
#define ClassRoadWorker 8
#define ClassParamedic  9
#define ClassFarmer     10
#define ClassSailor     11
#define ClassTrain      12
#define ClassTaxi       13




cb system
pawn Код:
/*
    CB Radio System; By Ash (funky1234)
    Do what you want with it, I don't really care.
    */


    #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;
    }
Reply
#2

anyone no ?
Reply
#3

anyone help
Reply
#4

Can this be made without Dcmd?
Reply
#5

i made it and works, tnx !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)