Jump to content
  • 0

[AJUTOR]SCM - SendClientMessage


Gawitkkk

Question

Nick: Gawitkkk

Problema: Am o problema la o comanda de admin, atunci cand nu esti admin, vreau sa trimita mesajul ca nu poti folos comanda deoarece nu esti admin, insa nu imi merge si tot nu stiu cum sa fac, textul apare dupa ce scriu comanda, adica.. tod 13...

Erori / warnings:

Lini/script:

if(strcmp(cmd, "/tod", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "Syntax: /tod [timeofday] (0-23)");
				return 1;
			}
			new hour;
			hour = strval(tmp);
			if (PlayerInfo[playerid][pAdmin] >= 5)
			{
	            SetWorldTime(hour);
				format(string, sizeof(string), "   Time set to %d Hours.", hour);
				BroadCast(COLOR_GRAD1, string);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "{5CAD5C}Error: Your admin level isn't high enough to use this command.");
			}
		}
		return 1;
	} 

Ai incercat sa rezolvi singur ?: Da.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

if(strcmp(cmd, "/tod", true) == 0)

    {

        if(IsPlayerConnected(playerid))

        {

            tmp = strtok(cmdtext, idx);

            if(!strlen(tmp))

            {

                SendClientMessage(playerid, COLOR_GRAD2, "Syntax: /tod [timeofday] (0-23)");

                return 1;

            }

            new hour;

            hour = strval(tmp);

            if (PlayerInfo[playerid][pAdmin] >= 5)

            {

                SetWorldTime(hour);

                format(string, sizeof(string), "  Time set to %d Hours.", hour);

                BroadCast(COLOR_GRAD1, string);

            }

            else SendClientMessage(playerid, COLOR_GRAD1, "{5CAD5C}Error: Your admin level isn't high enough to use this command.");

        }

        return 1;

    }

8ffTNVU.png

Link to comment
Share on other sites

Încearcă asta şi spune-mi dacă merge:

[pawn]if(strcmp(cmd, "/tod", true) == 0)

{

if(PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, COLOR_GRAD1, "{5CAD5C}Error: Your admin level isn't high enough to use this command.");

tmp = strtok(cmdtext, idx);

if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GRAD2, "Syntax: /tod [timeofday] (0-23)");

new hour;

hour = strval(tmp);

SetWorldTime(hour);

format(string, sizeof(string), "  Time set to %d Hours.", hour);

BroadCast(COLOR_GRAD1, string);

return 1;

} [/pawn]

p.s: nu-ţi trebuie IsPlayerConnected la asta, mai ales că în parametri nu ceri nici un playerid. ce faci tu acolo era un fix pentru un bug din SA-MP 0.1b când comenzile trimise de cineva puteau fi executate după ce au plecat de pe server, dar au trecut ceva ani de atunci :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.