More Efficient way of Global Chat? - 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: More Efficient way of Global Chat? (
/showthread.php?tid=203703)
More Efficient way of Global Chat? -
randomkid88 - 27.12.2010
I'm trying to make an efficient /ooc command but right now, I'm stuck using strtok, and with this, it cuts off the first word of whatever you type.
I want to use sscanf but I can't figure out how to make it work where its independent of what they type. For example, if I make it
pawn Code:
sscanf(params, "s", chat)
but the first character they type in is a number, it wont work, and I don't want to limit them to only starting with letters.
Thanks in advance for help, feel free to ask for any clarifications, I could have just rambled uncontrollably
Re: More Efficient way of Global Chat? -
MadeMan - 27.12.2010
Post your /ooc command.
Re: More Efficient way of Global Chat? -
randomkid88 - 27.12.2010
I couldn't figure one out, so I took this from Raven's and (tried) to mod it for zcmd
pawn Code:
CMD:o(playerid, params[])
{
new tmp[30], idx,length = strlen(params), Name[24], string[160];
tmp = strtok(params, idx);
GetPlayerName(playerid, Name, sizeof(Name));
while ((idx < length) && (params[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = params[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_RED, "[Server] Usage: /o [OOC chat]");
return 1;
}
format(string, sizeof(string),"(( %s[%i]: %s ))", Name, playerid, result);
SendClientMessageToAll(COLOR_NEUTRALBLUE, string);
return 1;
}
Re: More Efficient way of Global Chat? -
MadeMan - 27.12.2010
pawn Code:
CMD:o(playerid, params[])
{
new Name[24], string[160];
GetPlayerName(playerid, Name, sizeof(Name));
new result[128];
if(sscanf(params, "s", result)) return SendClientMessage(playerid, COLOR_RED, "[Server] Usage: /o [OOC chat]");
format(string, sizeof(string),"(( %s[%i]: %s ))", Name, playerid, result);
SendClientMessageToAll(COLOR_NEUTRALBLUE, string);
return 1;
}
Re: More Efficient way of Global Chat? -
randomkid88 - 27.12.2010
Yeah, I knew about that, but this won't work if the first character is a number, right? I don't want to have to limit this.
Re: More Efficient way of Global Chat? -
MadeMan - 27.12.2010
It should work.