Jump to content

Schimba culoarea playerului dupa factiune


xLays

Recommended Posts

INTRODUCERE

In acest tutorial vom invata cum sa modificam chatul astfel incat, atunci cand un jucator dintr-o anumita factiune scrie in chat, numele sau va aparea cu culoarea factiunii din care face parte.

De exemplu: Gigel din LCN scrie pe chat, o sa apara: Gigel:Salut iar daca Gigica din PD o sa scrie pe chat, va aparea asa: Gigica:Salut

Pasul 1:

Cautam linia:

forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);[code]


O dublam, prin dublare ma refer la faptul ca ii dam copy si paste din nou sub ea.Dupa aceea, schimbam numele celei de-a 2 functii in altceva ca de exemplu "culoarechat"

In final, sub linia ProxDetector vom avea aceasta linie:
[code]forward culoarechat(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
Pasul 2: Cautam linia :
public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)[code]


Dublam tot public-ul ProxDetector si inlocuim numele public-ului cu numele ales mai devreme cand l-am declarat, la mine este "culoarechat"

Public-ul ar trebui sa arate asa:

[code]public culoarechat(Float:radi, playerid, string[],col1,col2,col3,col4,col5)

{

    if(IsPlayerConnected(playerid))

    {

        new Float:posx, Float:posy, Float:posz;

        new Float:oldposx, Float:oldposy, Float:oldposz;

        new Float:tempposx, Float:tempposy, Float:tempposz;

        GetPlayerPos(playerid, oldposx, oldposy, oldposz);

        //radi = 2.0; //Trigger Radius

        for(new i = 0; i < MAX_PLAYERS; i++)

        {

            if(IsPlayerConnected(i))

            {

                if(!BigEar[i])

                {

                    GetPlayerPos(i, posx, posy, posz);

                    tempposx = (oldposx -posx);

                    tempposy = (oldposy -posy);

                    tempposz = (oldposz -posz);

                    //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);

                    if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))

                    {

                        SendClientMessage(i, col1, string);

                    }

                    else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))

                    {

                        SendClientMessage(i, col2, string);

                    }

                    else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))

                    {

                        SendClientMessage(i, col3, string);

                    }

                    else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))

                    {

                        SendClientMessage(i, col4, string);

                    }

                    else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))

                    {

                        SendClientMessage(i, col5, string);

                    }

                }

                else

                {

                    SendClientMessage(i, col1, string);

                }

            }

        }

    }//not connected

    return 1;

}
Pasul 3: In acelasi public pe care l-am creat mai devreme inlocuim toate functiile SendClientMessage cu SendPlayerMessageToPlayer Adica, in loc de
SendClientMessage(i, col1, string);
vom pune sub toate if-urile aceasta functie:
SendPlayerMessageToPlayer(i,playerid,string);
!!!ATENTIE: Inlocuiti toate functiile SendClientMessage din public-ul pe care l-ati creat, nu conteaza daca al 2-lea parametru e diferit fata de functia pe care am copiat-o pentru a va demonstra. Pasul 4: Acesta este pasul final, acum vom face o mica modificare la sistemul de scriere in chat de pe GF. Cautam linia:
if (realchat)
Vom vedea putin mai jos urmatoarele doua linii:
format(string, sizeof(string), "%s Says: %s", sendername, text);
ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
Pentru inceput, din prima linie scoatem parametrul "sendername" pentru ca nu ne mai trebuie acum deoarece functia SendPlayerMessageToPlayer arata si numele celui care trimite mesajul. Din a 2-a linie, modificam numele din ProxDetector in numele ales de noi mai devreme cand am creat publicul, si anume: culoarechat In final, cele 2 linii vor arata asa:
format(string, sizeof(string), "%s", text);
culoarechat(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);

Link to comment
Share on other sites

Join the conversation

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

Guest
Reply to this topic...

×   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.