16.01.2015, 12:53
HazardouS already told you the problem
if you want to use the function a bit more dynamic you should remove some parts
so it only modifies the string and doesn't send anything
You probably need to edit OnPlayerText also
if you want to use the function a bit more dynamic you should remove some parts
so it only modifies the string and doesn't send anything
pawn Код:
CheckQuickStrings(playerid, string[], size = sizeof string)
{
new idx = strfind(string, "$");
if(idx != -1)
{
do
{
if(strcmp(string[idx], "$loc", true, 4) == 0)
{
new zone[MAX_ZONE_NAME];
GetPlayer2DZone(playerid, zone, MAX_ZONE_NAME);
strdel(string, idx, idx + 4);
strins(string, zone, idx, size);
continue;
}
if(strcmp(string[idx], "$cash", true, 5) == 0)
{
new pmoney[32];
format(pmoney, sizeof(pmoney), "$%d",GetPlayerCash(playerid));
strdel(string, idx, idx + 5);
strins(string, pmoney, idx, size);
continue;
}
if(strcmp(string[idx], "$ply", true, 4) == 0)
{
new id = GetPlayerWhoIsClosest(playerid);
if(!IsPlayerConnected(id)) id = playerid;
new closeststr[32];
format(closeststr, sizeof(closeststr), "%s (%d)", PlayerInfo[id][pName], id);
strdel(string, idx, idx + 4);
strins(string, closeststr, idx, size);
continue;
}
}
while((idx = strfind(string, "$", false, idx + 1)) != -1);
return true;
}
return false;
}
pawn Код:
COMMAND:say(playerid, params[])
{
if (PlayerInfo[playerid][pSpawned] != 1)
return SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command When You're Dead.");
if (PlayerInfo[playerid][pMuted] == 1)
return SendClientMessage(playerid,COLOR_ERROR,"#Error: You Muted.");
if (!strlen(params))
return SendClientMessage(playerid, COLOR_ERROR, "USAGE: /me (message).");
if (stringContainsIP(params))
return SendClientMessage(playerid,COLOR_ERROR,"Invalid Message.");
new string[144];
strcat(string, params);
CheckQuickStrings(playerid, string); // replaces all tags inside string
format(string, sizeof(string), "%s (%d): %s",PlayerInfo[playerid][pName], playerid, string);
return SendClientMessageToAll(GetPlayerColor(playerid), string);
}
pawn Код:
new string[144];
strcat(string, text);
CheckQuickStrings(playerid, string);
SendPlayerMessageToAll(playerid, string);
return false;

