It sends only the Message to me.. - 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: It sends only the Message to me.. (
/showthread.php?tid=97396)
It sends only the Message to me.. -
Erkan - 14.09.2009
Код:
if(strcmp(cmd, "/msay", true) == 0)
{
if(PlayerData[playerid][Medic] < 1) return SendClientMessage(playerid, RED, "SERVER MESSAGE: You are not high enough");
if(PlayerData[playerid][Muted] == 1) return SendClientMessage(playerid, RED, "You have been muted, wait untill you are unmuted to talk");
if(PlayerData[playerid][Mduty] == 0) return SendClientMessage(playerid, RED, "You are not in Medic duty");
new otherplayer = strvalEx(tmp);
new pname[MAX_PLAYER_NAME];
new pname2[MAX_PLAYER_NAME];
GetPlayerName(otherplayer, pname, sizeof(pname));
GetPlayerName(playerid, pname2, sizeof(pname2));
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /msay [playerid] [text]");
return 1;
}
if(!IsPlayerConnected(otherplayer)) { SendClientMessage(playerid,RED,"SERVER MESSAGE: Incorrect ID"); return true; }
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
{
if(!strlen(result)) { SendClientMessage(playerid,WHITE,"Correct Usage: /msay [playerid] [text]"); return true; }
format(string, sizeof(string), "Medic %s says to you: %s", pname2, result);
SendClientMessage(otherplayer,TEAM_MEDIC,string);
}
return 1;
}
Re: It sends only the Message to me.. - Zeex - 14.09.2009
I really suggest you to stop to make such weird things like
pawn Код:
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
{
and start to use sscanf.
I've seen a lot of people doing like that, and I don't understand them all.... so it's not related only to you.
Re: It sends only the Message to me.. -
Erkan - 14.09.2009
Why sscanf result works, I need only id fixed?
Re: It sends only the Message to me.. -
Calgon - 14.09.2009
pawn Код:
dcmd_msay(playerid, params[])
{
new message[128], userid, string[128];
if (sscanf(params, "us", userid, message)) SendClientMessage(playerid, COLOR_WHITE, "SYNTAX - /msay [playerid] [message]");
else
{
if(PlayerData[playerid][Medic] < 1)
{
SendClientMessage(playerid, COLOR_WHITE, "You're not a medic!");
}
else
{
if(IsPlayerConnected(userid))
{
format(string, sizeof(string), "A medic message.. %s", message);
SendClientMessage(userid, COLOR_WHITE, string);
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "Invalid ID.");
}
}
}
return 1;
}
Re: It sends only the Message to me.. -
Jakku - 14.09.2009
pawn Код:
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
{
I think you'll not need things like this. Just as a tip :P