How to use custom functions inside custom functions.
#10

Quote:
Originally Posted by dominik523
View Post
I would suggest you to only use SendLocalMessage because you are using SendMeMessage in only /me command, right? So you can simply write something like this:
pawn Code:
stock ReturnName(playerid)
{
    new string[MAX_PLAYER_NAME];
    GetPlayerName(playerid, string, sizeof(string));
    return string;
}

SendLocalClientMessage(playerid, Float:range, color, str[])
{
    if (IsPlayerConnected(playerid))
    {
        new Float:ppos[3];
        GetPlayerPos(playerid, ppos[0], ppos[1], ppos[2]);
        foreach(Player, i)
        {
            if(IsPlayerInRangeOfPoint(i, range, ppos[0], ppos[1], ppos[2]))
            {
                SendClientMessage(i, color, str);
            }
        }
        return 1;
    }
    return 0;
}

CMD:me(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /me [action]");
    new string[128];
    format(string, sizeof(string), "* %s: %s", ReturnName(playerid), params);
    SendLocalClientMessage
    return 1;
}
SendLocalMessage is used in more than one command, so we are making function for it, while SendMeMessage is used only in /me so it's not that special to create it's own function.
Nope, still not working.

pawn Code:
CMD:seatbelt(playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid))
    {
        SendClientMessage(playerid, COLOR_GREY, "You are not inside a vehicle!");
    }
    else
    {
        new eqstr[1024], ueqstr[1024];
        //eqstr = CreatePlayerMeString(playerid, "reaches over to grab his seatbelt before clipping it in.");
        //ueqstr = CreatePlayerMeString(playerid, "reaches down to unclip his seatbelt before letting it slide back.");
        format(eqstr, sizeof(eqstr), "* %s reaches over to grab his seatbelt before clipping it in.", ReturnName(playerid));
        format(ueqstr, sizeof(ueqstr), "* %s reaches over to grab his seatbelt before clipping it in.", ReturnName(playerid));
        if(!IsPlayerSeatbelt(playerid))
        {
            SendLocalClientMessage(playerid, 30.0, COLOR_RP, eqstr);
            Seatbelt[playerid] = true;
        }
        else if(IsPlayerSeatbelt(playerid))
        {
            SendLocalClientMessage(playerid, 30.0, COLOR_RP, ueqstr);
            Seatbelt[playerid] = false;
        }
    }
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)