Jump to content
  • 0

PAWN - Chat


PartyGame

Dotaz

Zdravím komunito,

poprosil bych Vás, kdo by mi pomohl poradit s tímto kódem.

Jedná se o chat, když hráč má VIP, a hráč co nemá VIP, jestli tento kód je dobře (podmínky)

Jelikož mě to nějak blblo když jsem to měl else { a neměl jsem tam else if(HaveVIP(i) == 0), zda je to dobře tento kód nebo by to někdo udělal jinak?

Děkuji za odpovědi.

            if(HaveVIP(i) == 1)
            {
                format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string);
            }
            else if(HaveVIP(i) == 0)
            {
                format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string);
            }
Link to comment
Share on other sites

14 odpovědí na tuto otázku

Recommended Posts

  • 0

Dobře, takže tedy takhle:

            if(HaveVIP(playerid) == 1)
            {
                format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string);
            }
            else if(HaveVIP(playerid) == 0)
            {
                format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string)
            }
  • Haha! 1
Link to comment
Share on other sites

  • 0

No však  jedná se o zprávu do chatu, takže (i), takže tedy takto?

    ForMaxPlayer(i)
    {
            if(HaveVIP(playerid) == 1)
            {
                format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string);
            }
            else if(HaveVIP(playerid) == 0)
            {
                format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string);
            }
    }
Link to comment
Share on other sites

  • 0

Chápu pokud to posíláš přes SendClientMessage, tak ano, jinak by to mělo stačit takto

public OnPlayerText(playerid, text[])
{
  	if(HaveVIP(playerid) == 1)
	{
	    format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,text);
	}
	else if(HaveVIP(playerid) == 0)
	{
	    format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,text)
	}
	SendClientMessageToAll(-1,STR);
	return 0;
}

 

Edited by DeLeTeCZ
  • Líbí se mi to! (+1) 1
Link to comment
Share on other sites

  • 0

Ještě dodám, že i pokud to chceš z nějakého důvodu přes SendClientMessage tak i tak, jak to máš ty se to zbytečně formátuje při každém průchou cyklu

public OnPlayerText(playerid, text[])
{
  	if(HaveVIP(playerid) == 1)
	{
	    format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,text);
	}
	else if(HaveVIP(playerid) == 0)
	{
	    format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,text)
	}

	ForMaxPlayers(i)
	{
		SendClientMessage(i,-1,STR);
	}
	return 0;
}

 

Edited by DeLeTeCZ
  • Líbí se mi to! (+1) 1
Link to comment
Share on other sites

  • 0

Však tento můj kod není dobře?

    ForMaxPlayer(i)
    {
            if(HaveVIP(playerid) == 1)
            {
                format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string);
            }
            else if(HaveVIP(playerid) == 0)
            {
                format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string);
            }
    }
Link to comment
Share on other sites

  • 0

Opravuji, takto:

   ForMaxPlayer(i)
    {
        if(HaveVIP(playerid) == 1)
        {
            new STR[456];
            format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string);
            SCM(i, GetPlayerColor(playerid), STR);
        }
        else if(HaveVIP(playerid) == 0)
        {
            new STR[456];
            format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string);
            SCM(i, GetPlayerColor(playerid), STR);
        }
    }
Link to comment
Share on other sites

  • 0
před 45minutami, PartyGame said:

nebo by to někdo udělal jinak?

Já bych to udělal jinak, protože máš dvě podmínky pokud ale nemáš jinak.

// Někdo napsal do chatu:
public OnPlayerText(playerid, text[]) {
	/*
		playerid = ID toho hráče, co napsal do chatu,
		text[] = Text toho hráče co napsal do chatu
	*/

	// Jestliže má vip:
	if (HaveVIP(playerid) == 1) { // <--- Zde máš svoje "pokud"

		// Tak mu formátujeme zprávu, že jde o VIP hráče:
		format(STR, sizeof(STR), "[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s", GetPlayerColor(playerid) >>> 8, PlayerName(playerid), playerid,string);
	}
	//V případě ale, že ho nemá:
	else { // <--- Zde máš svoje "jinak"
		// Tak se formátuje obyčejná zpráva:
		format(STR, sizeof(STR), "[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s", GetPlayerColor(playerid) >>> 8,PlayerName(playerid), playerid, string);
	}
	// Tak či tak, se jedna ze formátovaných zpráv všem na serveru napíše:
	SendClientMessageToAll(0xA9C4E400, STR);
	return 0;
}

 

Edited by Scydo
  • Paráda! (+1) 1
  • Líbí se mi to! (+1) 2
Link to comment
Share on other sites

  • 0
před 13hodinami, PartyGame said:

Opravuji, takto:

   ForMaxPlayer(i)
    {
        if(HaveVIP(playerid) == 1)
        {
            new STR[456];
            format(STR, sizeof(STR), "{A9C4E4}[ VIP Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string);
            SCM(i, GetPlayerColor(playerid), STR);
        }
        else if(HaveVIP(playerid) == 0)
        {
            new STR[456];
            format(STR, sizeof(STR), "{A9C4E4}[ Hráč ] {%06x}%s | %d |: {FFFFFF}%s",(GetPlayerColor(playerid) >>> 8),PlayerName(playerid),playerid,string);
            SCM(i, GetPlayerColor(playerid), STR);
        }
    }

Jde vidět, že to cpeš do zdrojáku od PW a nevíš co to dělá. ForMaxPlayer je definice cyklu for, který projede všechny hráče na serveru a to je kravina. ForMaxPlayer u PW používal například pro to aby administrátoři viděli příkazy co hráči píšou, PMka a podobně. Takže cyklus zahoď a postupuj podle návodu od @Scydo

Edited by Paulee
  • Děkuji (+1) 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...