PDA

View Full Version : HELP SendClientMessage?? +Rep


Mijata
28/01/2015, 08:01 PM
why is message is not full

http://i.imgur.com/h4MSiPy.png

public OnPlayerConnect(playerid)
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"{E81010}***%s {1DB8F5}has joined the Server {00CF00}(Joined)*** !",pName);
SendClientMessageToAll(-1,string);
return 1;

}

public OnPlayerDisconnect(playerid, reason)
{
new
szString[64],
name[MAX_PLAYER_NAME];

GetPlayerName(playerid, name, MAX_PLAYER_NAME);

switch(reason)
{
case 0: format(szString, sizeof szString, "{E81010}*** %s {1DB8F5}left the Server.{00CF00}(Timed Out/Crashed)***", name);
case 1: format(szString, sizeof szString, "***{E81010}%s {1DB8F5}left the Server.{00CF00}(Quit)***", name);
case 2: format(szString, sizeof szString, "***{E81010}%s {1DB8F5}left the Server.{00CF00}(Kicked/Banned)***", name);
}

SendClientMessageToAll(-1, szString);
return 1;
}

Jefff
28/01/2015, 08:03 PM
Change [64] to [128]

arlindi
28/01/2015, 08:04 PM
new string[124], pName[MAX_PLAYER_NAME]; // This

new
szString[124], // and this

Mijata
28/01/2015, 08:04 PM
thanks + rep for u

AdamsP
28/01/2015, 08:08 PM
Yes bro, you need either string length 124 or 128. 128 characters is the max for Sendclientmessages.

Mijata
28/01/2015, 08:12 PM
how to create here when is admin on duty message for all admin is now on duty and admin is now off duty

CMD:aduty(playerid, params[])
{
if(pInfo[playerid][pLevel] >= 1)
{
new skin[MAX_PLAYERS];
if(OnDuty[playerid] == 0)
{
skin[playerid] = GetPlayerSkin(playerid);
SetPlayerSkin(playerid, 217);
SetPlayerHealth(playerid, 100000);
SetPlayerArmour(playerid, 100000);
SetPlayerColor(playerid, 0x01FCFFFF);
OnDuty[playerid] = 1;
}
else if(OnDuty[playerid] == 1)
{
SetPlayerSkin(playerid, skin[playerid]);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
SetPlayerColor(playerid, 0xFFFFFFFF);
OnDuty[playerid] = 0;
}
}
else
{
SendClientMessage(playerid, red, "You are not administrator.");
}
return true;
}

Sawalha
28/01/2015, 08:18 PM
add this under those statements:

new msg[128], aname[MAX_PLAYER_NAME];
if(OnDuty[playerid] == 0)
{
skin[playerid] = GetPlayerSkin(playerid);
SetPlayerSkin(playerid, 217);
SetPlayerHealth(playerid, 100000);
SetPlayerArmour(playerid, 100000);
SetPlayerColor(playerid, 0x01FCFFFF);
OnDuty[playerid] = 1;
GetPlayerName(playerid, aname, sizeof aname);
format(msg, sizeof msg, "%s is now on Administrator duty.", aname);
SendClientMessageToAll(-1, msg); // you may change -1 to any other color
}


and:

else if(OnDuty[playerid] == 1)
{
SetPlayerSkin(playerid, skin[playerid]);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
SetPlayerColor(playerid, 0xFFFFFFFF);
OnDuty[playerid] = 0;
GetPlayerName(playerid, aname, sizeof aname);
format(msg, sizeof msg, "%s is now off Administrator duty.", aname);
SendClientMessageToAll(-1, msg);
}

P.S : you may define 'aname' and 'msg' variables in the command out of those statements, so you don't have to define them twice.
and , your code would be better if you add indentation to it.

arlindi
28/01/2015, 08:20 PM
CMD:aduty(playerid)
{
if(pInfo[playerid][pLogged] == 1)
{
if(pInfo[playerid][pAdminLevel] >= 1)
{

if(pInfo[playerid][pAdminDuty] == 0)
{
pInfo[playerid][pAdminDuty] = 1;
SetPlayerSkin(playerid, skin[playerid]);
SetPlayerHealth(playerid, 100);
SetPlayerArmour(playerid, 0);
SetPlayerColor(playerid, 0xFFFFFFFF);
OnDuty[playerid] = 0;
}
else
{
if(pInfo[playerid][pAdminDuty] == 1)
{
pInfo[playerid][pAdminDuty] = 0;
SetPlayerHealth(playerid,100);
}
}
}
}