Admin say problem - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Admin say problem (
/showthread.php?tid=242050)
Admin say problem -
Soumi - 19.03.2011
Hello everyone , i made an /asay command that allows the admin to send a message to the players. i compiled the .pwn file and there is no errors/warnings , but in game , the command is not working...
Maybe you can tell me what should i do..
Here's the cmd
PHP код:
if(!strcmp(cmd, "/asay2"))
{
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
new text[128], string[128];
if(sscanf(params, "s[128]",text)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /asay [text]");
else
{
new pName[128];
GetPlayerName(playerid,pName,128);
format(string,sizeof string,"~b~%s:~r~%s",pName,text);
GameTextForAll(string,3000,4);
}
}
return 1;
}
Re: Admin say problem -
Biesmen - 19.03.2011
How do you want to use SSCANF with strcmp?
Use DCMD, ZCMD. A command plugin which supports params.
Re : Re: Admin say problem -
Soumi - 19.03.2011
Quote:
Originally Posted by Biesmen
How do you want to use SSCANF with strcmp?
Use DCMD, ZCMD. A command plugin which supports params.
|
Well , i used SSCANF With strcmp to create many commands /kick , /ban , /freeze , /mute and many other commands
and i don't know what is this cmd problem , Help me please?
Re: Admin say problem -
Biesmen - 19.03.2011
But how do you use the params if it's not defined? Or is it defined somewhere else in the callbakc OnPlayerCommand?
Well, anyway, let's try this code then:
pawn Код:
if(!strcmp(cmd, "/asay2"))
{
new text[128], string[128];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFFFFFFFF,"You are not an admin !");
if(sscanf(params, "s[128]",text)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /asay2 [text]");
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "~b~%s:~r~%s",pName, text);
GameTextForAll(string, 3000, 4);
return 1;
}
You used too many unnecessarily brackets, and you used else for no reason, and pName should be MAX_PLAYER_NAME, which will make the small chance of lag even more small.
Re : Admin say problem -
Soumi - 19.03.2011
Mhmm... I tested this but , still not working !! nothing changed , when i type like /asay2 Hello , it shows /asay2 [text]..