Jump to content
  • 0

Problema cu playerid si player , comanda /me.


Question

Posted

Salut ! Am urmatorul script :

 

CMD:me(playerid,text[])
{
     if(sscanf(text,"s")==0)
     {
         new action[128] = ">PLAYER_NAME ACTION";
         strreplace(action,"PLAYER_NAME",player_name);
         strreplace(action,"ACTION",text);
         SendClientMessage(playerid,COLOR_PURPLE,action);
         for (new player=0;player<MAX_PLAYERS;player++)
         {
             new Float:x, Float:y, Float:z;
             GetPlayerPos(player,x,y,z);
             if(playerid!=player)
             {
                 if(GetPlayerDistanceFromPoint(player,x,y,z)<6) SendClientMessage(player,COLOR_PURPLE,action);
             }
             
         }
         return 1;

     }
     else return 0;
}

Ce vreau eu sa faca : daca jucatorul X da comanda "/me fumeaza o tigara." sa apara in chat ">X fumeaza o tigara.". Asta intr-un range calculat cu fiecare player prim structura for.
Totusi, am testat pe LAN cu doua calculatoare si sunt 2 mari probleme :
Mesajul apare global, indiferent de distanta dintre cei doi playeri.

Daca am jucatorii X si Y, si Y da comanda "/me", apare ca si cum a dat-o X.

6 answers to this question

Recommended Posts

  • 0
Posted

Incearca sa trimiti mesajul cu un ProxDetector...

Link cu functia: https://pastebin.com/WzySZASw

Si cam asa ar arata comanda

YCMD:me(playerid,params[], help) {
    new string[200],result[128];
    if(sscanf(params, "s[128]",result)) return sendUsage(playerid, "/me [action]");

    format(string, sizeof(string), "* (/me) %s %s", GetName(playerid), result);
    ProxDetector(12.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);

    format(string, sizeof(string), "* (/me) %s %s", GetName(playerid), result);
    return 1;
}

Eu asa am functia din gamemode, poti sterge col1, col2, sa nu mai pui atatea COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE.

exemplu:https://pastebin.com/mzv2ncSS

 ProxDetector(12.0, playerid, string, COLOR_PURPLE);

Nu am mai scriptat de 2 ani, daca am gresit ceva, rog pe cineva sa ma corecteze :)

  • 0
Posted (edited)

CMD:me(playerid, text[]) 
{
    if(!strlen(text))
        return 1;
        
    new 
        playerName[MAX_PLAYER_NAME], 
        message[144];

    GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);

    format(message, sizeof message, "> %s %s", playerName, text);

    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);

    for(new i = 0; i < MAX_PLAYERS; ++i)
    {      
        if(IsPlayerStreamedIn(i, playerid) && IsPlayerInRangeOfPoint(i, 6.0, x, y, z))
            SendClientMessage(i, COLOR_PURPLE, message);
    }
    return 1;
}

Edited by Sancky
edit: imbunatatiri, sscanf-ul e cam useless in cazul asta, n-avem ce parametrii sa delimitam
  • Upvote 1
  • 0
Posted
7 hours ago, Sancky said:

CMD:me(playerid, text[]) 
{
    new message[116];

    if(strlen(text) > 116 || sscanf(text, "s[116]", message)) 
        return 1;
        
    new playerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
    
    format(message, sizeof message, "> %s %s", playerName, message);

    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);

    for(new i = 0; i < MAX_PLAYERS; ++i)
    {      
        if(IsPlayerInRangeOfPoint(i, 6.0, x, y, z))
            SendClientMessage(i, COLOR_PURPLE, message);
    }
    return 1;
}

 

incearca asa, dar nu stiu sigur daca va merge formatarea aia pe acelasi array, daca nu mg definesti alt array si il formatezi p-ala

CMD:me(playerid, params[], help) {
    extract params -> new string:text[128]; else return SendClientMessage(playerid, COLOR_WHITE, "me [text]");
 
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
 
    for(new i = 0; i < MAX_PLAYERS; ++i) if(IsPlayerInRangeOfPoint(i, 15.0, x, y, z)) va_SendClientMessage(i, COLOR_PURPLE, "%s say %s", GetName(playerid), text);
    return true;
}
  • 0
Posted
14 minutes ago, mrrares19 said:
CMD:me(playerid, params[], help) {
    extract params -> new string:text[128]; else return SendClientMessage(playerid, COLOR_WHITE, "me [text]");
 
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
 
    for(new i = 0; i < MAX_PLAYERS; ++i) if(IsPlayerInRangeOfPoint(i, 15.0, x, y, z)) va_SendClientMessage(i, COLOR_PURPLE, "%s say %s", GetName(playerid), text);
    return true;
}

ce?

  • 0
Posted

Salut, incearca comanda asta:

CMD:me(playerid, params[])
{
    if(isnull(params) || strlen(params) < 3)
    {
        return SendClientMessage(playerid, 0xFFFFFFFF, "/me [action]");
    }

    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));

    new message[128];
    format(message, sizeof(message), "(/me) * %s: %s", name, message);
    return SendNearbyMessage(playerid, COLOR_PURPLE, message);
}


Inainte de comanda / dupa, e alegerea ta, adauga si urmatorul stock:

stock SendNearbyMessage(playerid, color, message[], Float:distance = 15.0)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);

    for(new player = 0; player < MAX_PLAYERS; player++)
    {
        if(GetPlayerVirtualWorld(player) != GetPlayerVirtualWorld(playerid)) continue;
        if(GetPlayerInterior(player) != GetPlayerInterior(playerid)) continue;
        if(GetPlayerDistanceFromPoint(player) > distance) continue;

        SendClientMessage(player, color, message);
    }

    return 1;
}
  • 0
Posted (edited)
53 minutes ago, irinelbro69 said:

Salut, incearca comanda asta:

CMD:me(playerid, params[])
{
    if(isnull(params) || strlen(params) < 3)
    {
        return SendClientMessage(playerid, 0xFFFFFFFF, "/me [action]");
    }

    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));

    new message[128];
    format(message, sizeof(message), "(/me) * %s: %s", name, message);
    return SendNearbyMessage(playerid, COLOR_PURPLE, message);
}


Inainte de comanda / dupa, e alegerea ta, adauga si urmatorul stock:

stock SendNearbyMessage(playerid, color, message[], Float:distance = 15.0)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);

    for(new player = 0; player < MAX_PLAYERS; player++)
    {
        if(GetPlayerVirtualWorld(player) != GetPlayerVirtualWorld(playerid)) continue;
        if(GetPlayerInterior(player) != GetPlayerInterior(playerid)) continue;
        if(GetPlayerDistanceFromPoint(player) > distance) continue;

        SendClientMessage(player, color, message);
    }

    return 1;
}

cea mai buna solutie e sus pentru ce are el, nu mai trimiteti tot felu de variante daca nu-s mai bune fata de 

p.s: GetPlayerDistanceFromPoint are lipsa niste argumente, also exista IsPlayerStreamedIn pt vw/int, si declararea array-ului msg ca constanta deoarece nu si schimba valoarea

Edited by Sancky

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.