SA-MP Forums Archive
What's the code for.. - 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)
+--- Thread: What's the code for.. (/showthread.php?tid=331727)



What's the code for.. - JonesyFoCoTDM - 05.04.2012

I know it's out there some where, but I can't seem to find it. Basically, I'm after the code to send a global message.

I want it so like.. When someone uses "/sethp 100" a message will come up letting the whole server know that said player has done it.

+REP to the 1st guy that gives me it!


Re: What's the code for.. - ViniBorn - 05.04.2012

Use SendClientMessageToAll


Re: What's the code for.. - JonesyFoCoTDM - 05.04.2012

Top man, thanks.


Re: What's the code for.. - [GF]Logic - 05.04.2012

hmm let's see try sendclientmessagetoall


Re: What's the code for.. - Knight_Rider - 05.04.2012

i also want this thanx


Respuesta: What's the code for.. - Chris1337 - 05.04.2012

ZCMD

pawn Код:
{ //Now, we will be needing a user variable for the Player ID, and a Integer variable for the amount.
    new player, health, string[128], administrator[MAX_PLAYER_NAME];
    if(!sscanf(params, "ui", player, health))
    {
        if(player != INVALID_PLAYER_ID)
        {
            if(SInfo[playerid][pAdmin] >= 0)
            {
                GetPlayerName(playerid, administrator, sizeof(administrator));
                SetPlayerHealth(player, health);
                format(string, sizeof(string), "[ADMIN]: Player ID %d's HP has been set to %d by %s.", player, health, administrator);
SendClientMessageToAll(0xDEEE20FF, string);
                AChat(ADMIN, string, 1); //Broadcasts a message to every administrator.
                printf(string);
            }
            else return SendClientMessage(playerid, ROJO, "[Command not found on GTACNR , use /cmds or /commands to see it ]"); //If you're not an Administrator it will send you this client message.
        }
        else return SendClientMessage(playerid, ROJO, "[ERROR]: That user ID is not connected."); //If you enteROJO an INVALID_PLAYER_ID, it will send you this client message.
    }
    else return SendClientMessage(playerid, CELESTE, "[USAGE]: /SetHP [Player ID/Part of Name] [Amount]"); //If you enteROJO the wrong syntax, it will send you this, telling you the exact syntax.
    return 1; //Always include a return 1; after the syntax, or you will get "SERVER: Unknown Command."
}



Re: What's the code for.. - JonesyFoCoTDM - 05.04.2012

I don't have any admin stuff on my server, it's just going to be ran from my computer for a few friends to mess about on with me really, and to learn more about scripting. I've just added "SendClientMessageToAll" and well.. I'm having some problems with it.

Quote:

if(strcmp("/sethp 100", cmdtext, true))
{
SetPlayerHealth(playerid, 100);
SendClientMessage(playerid, 0xAFAFAFAA, "(MESSAGE) You have just set your HP to 100");
SendClientMessageToAll(playerid, 0xAFAFAFAA "(MESSAGE) Has just set their HP to 100!");
return 1;
}

Quote:

C:\Users\Jonesy\Desktop\SA-MP scripting\gamemodes\bare.pwn(45) : error 035: argument type mismatch (argument 2)
C:\Users\Jonesy\Desktop\SA-MP scripting\gamemodes\bare.pwn(45) : warning 215: expression has no effect
C:\Users\Jonesy\Desktop\SA-MP scripting\gamemodes\bare.pwn(45) : error 001: expected token: ";", but found ")"
C:\Users\Jonesy\Desktop\SA-MP scripting\gamemodes\bare.pwn(45) : error 029: invalid expression, assumed zero
C:\Users\Jonesy\Desktop\SA-MP scripting\gamemodes\bare.pwn(45) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.




Re: What's the code for.. - Tomer!.$ - 05.04.2012

PHP код:
if(strcmp("/sethp 100"cmdtexttrue))
{
SetPlayerHealth(playerid100);
SendClientMessage(playerid0xAFAFAFAA"(MESSAGE) You have just set your HP to 100.");
format(stringsizeof(string), "(MESSAGE) %s Has just set his health to 100.");
SendClientMessageToAll(0xAFAFAFAAstring);
return 
1;




Re: What's the code for.. - tpolis - 05.04.2012

Which is role 45?


Re: What's the code for.. - JonesyFoCoTDM - 05.04.2012

Still get these errors mate.

Quote:

C:\Users\Jonesy\Desktop\SA-MP scripting\gamemodes\bare.pwn(45) : error 017: undefined symbol "string"
C:\Users\Jonesy\Desktop\SA-MP scripting\gamemodes\bare.pwn(45) : error 017: undefined symbol "string"
C:\Users\Jonesy\Desktop\SA-MP scripting\gamemodes\bare.pwn(45) : error 029: invalid expression, assumed zero
C:\Users\Jonesy\Desktop\SA-MP scripting\gamemodes\bare.pwn(45) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

That's after compiling this:

Quote:

if(strcmp("/sethp 100", cmdtext, true))
{
SetPlayerHealth(playerid, 100);
SendClientMessage(playerid, 0xAFAFAFAA, "(MESSAGE) You have just set your HP to 100.");
format(string, sizeof(string), "(MESSAGE) %s Has just set his health to 100.");
SendClientMessageToAll(0xAFAFAFAA, string);
return 1;
}