SA-MP Forums Archive
Lil help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Lil help (/showthread.php?tid=243405)



Lil help - tanush - 23.03.2011

Well i make vip chat but when i type in /vchat and talk it works and i could hear my other friend but when i type, he cant see what i typed or what he typed
pawn Код:
CMD:vchat(playerid, params[])
{
    new id,str[128], name[MAX_PLAYER_NAME];
    if(sscanf(params,"s",str)) return SendClientMessage(playerid,0xFF9900AA, "USAGE: /vchat [text]");
    GetPlayerName(playerid,name,sizeof(name));
    format(str, sizeof(str), "[VIPCHAT] %s: %s",name,str);
    {
        if(IsPlayerConnected(id))
        {
            if(PlayerData[playerid][vip] > 0)
            {
            SendClientMessage(id,0xFF9900AA,str);
            }
        }
    }
    return 1;
}



Re: Lil help - [L3th4l] - 23.03.2011

That's now how you properly create a cmd.
pawn Код:
CMD:vchat(playerid, params[])
{
    new
        pID,
        pName[MAX_PLAYER_NAME],
        iStr[128];

    if(sscanf(params, "us[128]", pID, params)) return SendClientMessage(playerid, 0xFF9900AA, "USAGE: /vchat [text]"); // Assuming you are using sscanf2, if not change to: "us"

    GetPlayerName(pID, pName, sizeof(pName));

    format(iStr, sizeof(iStr), "[VIPCHAT] %s: %s", pName, params);
    if(IsPlayerConnected(pID)) SendClientMessage(pID, 0xFF9900AA, iStr);

    return 1;
}



Re: Lil help - tanush - 23.03.2011

it wont work i get USAGE: /vchat [text]


Re: Lil help - [L3th4l] - 23.03.2011

Ops, my bad. I read it wrong, try this:
pawn Код:
CMD:vchat(playerid, params[])
{
    if(PlayerData[playerid][vip] < 0) return SendClientMessage(playerid, 0xFF9900AA, "You cannot use this command!");

    new
        iName[MAX_PLAYER_NAME],
        iStr[128];

    if(isnull(params)) return SendClientMessage(playerid, 0xFF9900AA, "Usage: /VChat < Message >");

    GetPlayerName(playerid, iName, sizeof(iName));

    for(new i = 0; i < MAX_PLAYERS; ++i)
    {
        if(IsPlayerConnected(i) && !IsPlayerNPC(i))
        {
            if(PlayerData[i][vip] > 0)
            {
                format(iStr, sizeof(iStr), "[VIPCHAT] %s: %s", iName, params);
                SendClientMessage(i, 0xFF9900AA, iStr);
            }
        }
    }
    return 1;
}