messages not being said to all players :S -
[LHT]Bally - 27.01.2013
i have a few commands and the messages arent saying the correct thing
pawn Код:
This one just says Player bla has been exploded by bla < so basically same name used twice
pawn Код:
COMMAND:explode(playerid,params[])
{
SendAdminText(playerid, "/explode", params);
if(APlayerData[playerid][PlayerLevel] == 1) return SendClientMessage(playerid,0xff0000ff,"You aren't an admin");
new pid, PlayerToblow[128], pname[32], Msg[128];
if(sscanf(params,"u",pid))return SendClientMessage(playerid,0xff0000FF,"ERROR: Usage /explode [playerid/name]");
if(pid != INVALID_PLAYER_ID && IsPlayerConnected(pid))
{
new Float:x,Float:y,Float:z;
GetPlayerPos(pid,x,y,z);
CreateExplosion(x,y,z,0,5.0);
GetPlayerName(playerid,pname,32);
GetPlayerName(playerid,PlayerToblow,128);
GameTextForPlayer(pid,"BOOM!",3000,3);
format(Msg, 128, "Player %s Has Been {ff0000}EXPLODED {ffff00}By: %s", PlayerToblow, pname);
SendClientMessageToAll(0xFFFF00FF, Msg);
return 1;
}
else SendClientMessage(playerid,0xff0000FF,"ERROR: Player not found");
return 1;
}
pawn Код:
This one says Player Has been warned By blaa For Blaa << the name of player warned doesnt get used and the admin who did it gets his name and the admin who warned and for the reason :S
pawn Код:
COMMAND:warn(playerid, params[])
{
new PlayerToWarn, Reason[128], ReasonMsg[128], Name[24], AdminNlame[128], Msg[256];
// Send the command to all admins so they can see it
SendAdminText(playerid, "/warn", params);
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 1
if (APlayerData[playerid][PlayerLevel] >= 1)
{
if (sscanf(params, "us[128]", PlayerToWarn, Reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/warn <PlayerToWarn> <Reason>\"");
else
if (IsPlayerConnected(PlayerToWarn)) // If the player is a valid playerid (he's connected)
{
// Increase the number of warnings
APlayerData[PlayerToWarn][Warnings]++;
// Get the name of the player who warned the player
GetPlayerName(playerid, Name, sizeof(Name));
// Send the warned player a message who warned him and why he's been warned
format(ReasonMsg, 128, "You have been warned by %s %s", AdminLevelName[APlayerData[playerid][PlayerLevel]], Name);
SendClientMessage(PlayerToWarn, 0xFF0000FF, ReasonMsg);
format(ReasonMsg, 128, "Reason: %s", Reason);
SendClientMessage(PlayerToWarn, 0xFF0000FF, ReasonMsg);
// Get the name of the warned player
GetPlayerName(PlayerToWarn, Name, sizeof(Name));
GetPlayerName(playerid,AdminNlame,128);
// Let the admin know who has been warned and why
format(ReasonMsg, 128, "You have warned %s (warnings: %i/%i)", Name, APlayerData[PlayerToWarn][Warnings], AutoKickWarnings);
SendClientMessage(playerid, 0x00FF00FF, ReasonMsg);
format(ReasonMsg, 128, "Reason: %s", Reason);
SendClientMessage(playerid, 0xFF0000FF, ReasonMsg);
format(Msg, 128, "Player %s Has Been Warned By Administrator: %s For %s ", PlayerToWarn, Name, AdminNlame, Reason);
SendClientMessageToAll(0xffff00FF, Msg);
// Automatically kick the player if he got 3 warnings (if autokick is enabled)
if ((APlayerData[PlayerToWarn][Warnings] == AutoKickWarnings) && (AutoKickAfterWarn == 1))
Kick(PlayerToWarn);
}
else
SendClientMessage(playerid, 0xFF0000FF, "That player isn't online");
}
else
return 0;
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
Re: messages not being said to all players :S -
Babul - 27.01.2013
in the top script, youre using playerid twice:
Код:
GetPlayerName(playerid,pname,32);
GetPlayerName(playerid,PlayerToblow,128);
in the bottom script, pay attention to the parameter count:
Код:
format(Msg, 128, "Player %s Has Been Warned By Administrator: %s For %s ", PlayerToWarn, Name, AdminNlame, Reason);
its 3 strings being parsed, and being fed to format().
oh, since IAM the master of typos: remove the "AdminNlame", and use "AdminName" heheh
Re: messages not being said to all players :S -
[LHT]Bally - 27.01.2013
i dont get how to fix the explode one
Re: messages not being said to all players :S -
Mauzen - 27.01.2013
Make this
pawn Код:
GetPlayerName(playerid,pname,32);
GetPlayerName(playerid,PlayerToblow,128);
to this:
pawn Код:
GetPlayerName(playerid,pname,32);
GetPlayerName(pid,PlayerToblow,128);
You put the same name in both variables so its no wonder it also shows the same names.
Re: messages not being said to all players :S -
[LHT]Bally - 27.01.2013
Thanks seems ive failed at them all
like this 1
pawn Код:
COMMAND:kick(playerid, params[])
{
new PlayerToKick, Reason[128], Msg[128], ReasonMsg[128], Name[24];
// Send the command to all admins so they can see it
SendAdminText(playerid, "/kick", params);
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 1
if (APlayerData[playerid][PlayerLevel] >= 1)
{
if (sscanf(params, "us[128]", PlayerToKick, Reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/kick <PlayerToKick> <Reason>\"");
else
if (IsPlayerConnected(PlayerToKick)) // If the player is a valid playerid (he's connected)
{
// Get the name of the player who warned the player
GetPlayerName(playerid, Name, sizeof(Name));
// Send the warned player a message who kicked him and why he's been kicked
format(ReasonMsg, 128, "You have been kicked by %s %s", AdminLevelName[APlayerData[playerid][PlayerLevel]], Name);
SendClientMessage(PlayerToKick, 0xFF0000FF, ReasonMsg);
format(ReasonMsg, 128, "Reason: %s", Reason);
SendClientMessage(PlayerToKick, 0xFF0000FF, ReasonMsg);
// Kick the player
Kick(PlayerToKick);
format(Msg, 128, "Player %s Has Been Kicked For %s", PlayerToKick, Name );
SendClientMessageToAll(0x808080FF, Msg);
}
else
SendClientMessage(playerid, 0xFF0000FF, "That player isn't online");
}
else
return 0;
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
and this
pawn Код:
CMD:slap(playerid, params[])
{
SendAdminText(playerid, "/slap", params);
if(IsPlayerConnected(playerid))
{
new sID, PlayerToslap[128], pname[32], Msg[128];
if(APlayerData[playerid][PlayerLevel] < 1) return SendClientMessage(playerid, -1, "{ff0000}you are not admin");
if(sscanf(params, "u", sID)) return SendClientMessage(playerid, -1, "{ff0000}Usage /slap [ID]");
new Float:x, Float:y, Float:z, Float:nurk;
GetPlayerName(playerid,pname,32);
GetPlayerName(playerid,PlayerToslap,128);
GetPlayerPos(sID, x, y, z);
GetPlayerFacingAngle(sID, nurk);
SetPlayerPos(sID, Float:x, Float:y, Float:z+10);
SetPlayerFacingAngle(sID, Float: nurk);
format(Msg, 128, "Player %s Has Been {ff0000}SLAPPED {FFFF00}By: %s", PlayerToslap, pname);
SendClientMessageToAll(0xFFFF00FF, Msg);
}
return 1;
}