megaphone
#1

When I do my megaphone command, it doesnt return the message. All my other chats use proxdetect and they work fine, but this one simply does not. The error messages work fine if they have to.

pawn Код:
CMD:megaphone(playerid, params[])
{
    if(!IsPlayerLEO(playerid)) return ErrorMessage(pid, "You are not LEO.");
    new string[128], message[100];
    if(sscanf(params,"s", message)) return UsageMessage(pid, "/m(egaphpone) [message]");
    format(string, sizeof(string), "[Megaphone]: %s", message);
    ProxDetector(50.0, playerid, string, 0xFF8C00AA);
    return 1;
}
Reply
#2

Edit: Nevermind what I said, it was wrong.
Reply
#3

Set s to s[128]. In sscanf you need to set all strings to how "big" they are. Also I don't think you need to have message but you can use "string" for everything instead but up to you bud'.

Haven't tested it but according to what I wrote above it should be like this:

Код:
CMD:megaphone(playerid, params[])
{
    if(!IsPlayerLEO(playerid)) return ErrorMessage(pid, "You are not LEO.");
    new string[128], message[100];
    if(sscanf(params,"s[100]", message)) return UsageMessage(pid, "/m(egaphpone) [message]");
    format(string, sizeof(string), "[Megaphone]: %s", message);
    ProxDetector(50.0, playerid, string, 0xFF8C00AA);
    return 1;
}
But I'd rather just do this:
Код:
CMD:megaphone(playerid, params[])
{
    if(!IsPlayerLEO(playerid)) return ErrorMessage(pid, "You are not LEO.");
    new string[128];
    if(sscanf(params,"s[128]", string)) return UsageMessage(pid, "/m(egaphpone) [message]");
    format(string, sizeof(string), "[Megaphone]: %s", string);
    ProxDetector(50.0, playerid, string, 0xFF8C00AA);
    return 1;
}
But I'm not a professional but that's the only wrong thing I find. Test them, one of them should work if not both. For instance I'm using just one string variable in my "/me" and "/do" commands.
Reply
#4

ok i cant believe I missed that lol. But I tried it and adding "good" after each function, and they all work
the message just doesnt return for some reason

pawn Код:
CMD:megaphone(playerid, params[])
{
    if(!IsPlayerLEO(playerid)) return ErrorMessage(pid, "You are not LEO.");
    new string[128], message[100];
    if(sscanf(params,"s[100]", message)) return UsageMessage(pid, "/m(egaphpone) [message]");
    SCM(pid, -1, "Good1");
    format(string, sizeof(string), "[Megaphone]: %s", message);
    SCM(pid, -1, "Good2");
    ProxDetector(50.0, playerid, string, 0xFF8C00AA);
    SCM(pid, -1, "Good3");
    return 1;
}
Reply
#5

Don't know, it should work unless you messed up with the ProxDetector but you said other commands work so... What string variable name do you use in your ProxDectector? Like...

Код:
public ProxDetector(Float:yourFloatVariable, playerid, thisOne, ...
What do you use on thisOne? If you are using different well then you might have the solution but I am not 100% sure, not even 10% lol.
Reply
#6

the color...
Reply
#7

So basically you have no whatever-it's-called to send into the ProxDetector and work with? No string? For instance this is my practice script's /me command:

Код:
CMD:me(playerid, params[])
{
	new rpstring[128];

	if(sscanf(params, "s[128]", rpstring)) return SCM(playerid, 0xFFFFFFFF, "Usage: /me [action]");
	format(rpstring, sizeof(rpstring), "** %s %s", pName(playerid), rpstring);
	
	nearRP(30.0, playerid, rpstring, 0xAE00FFFF, 0xAE00FFFF, 0xAE00FFFF, 0xAE00FFFF, 0xAE00FFFF);

	return 1;
}
and this is how my public looks like for my "nearRP":

Код:
public nearRP(Float:radi, playerid, rpstring[], col1, col2, col3, col4, col5)
Your "ProxDetector(50.0, playerid, string, 0xFF8C00AA);" needs to match your ProxDetector's public thingy.
Reply
#8

Quote:
Originally Posted by Mattakil
Посмотреть сообщение
ok i cant believe I missed that lol. But I tried it and adding "good" after each function, and they all work
the message just doesnt return for some reason

pawn Код:
CMD:megaphone(playerid, params[])
{
    if(!IsPlayerLEO(playerid)) return ErrorMessage(pid, "You are not LEO.");
    new string[128], message[100];
    if(sscanf(params,"s[100]", message)) return UsageMessage(pid, "/m(egaphpone) [message]");
    SCM(pid, -1, "Good1");
    format(string, sizeof(string), "[Megaphone]: %s", message);
    SCM(pid, -1, "Good2");
    ProxDetector(50.0, playerid, string, 0xFF8C00AA);
    SCM(pid, -1, "Good3");
    return 1;
}
Check the server log and if there is sscanf warning: Strings without a length are deprecated, please add a destination size.
enlarge the placeholder size: message[128] or even to 256 cells ?
Reply
#9

no errors, and im not going over the string limit so thats not the issue. The message is what the player types, and the string is to add the [Megaphone]. Therefore, you need two strings.
Reply
#10

I didn't need two when I made my /me command. Use "string" instead of memory, but doubt it will actually solve the problem. The problem is probably in your Prox. Mind uploading it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)