) new idx = strfind(text, "$");
if(idx != -1)
{
new string[144];
strcat(string, text);
do
{
if(strcmp(string[idx], "$loc", true, 4) == 0)
{
strdel(string, idx, idx + 4);
strins(string, PlayerInfo[playerid][pLocation], idx);
continue;
}

if(strcmp(string[idx], "$loc", true, 4) == 0)
{
strdel(string, idx, idx + 4);
strins(string, PlayerInfo[playerid][pLocation], idx);
SendClientMessage(playerid,-1,"Here its visible");
continue;
}
|
are u sure the code is able to see this $loc in command?
try debugging with this PHP код:
|
|
so if you can't see SendClientMessage it means that your code is not working good.
can u post the whole command? from the beginning. |
COMMAND:pm(playerid, params[])
{
new idx,id,TargetID,string[256],tmp[256],cmd[256],message[256];
tmp = strtok(params, idx);
if (!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /pm (Name/Id) (message).");
return 1;
}
if (PlayerInfo[playerid][pMuted] == 1)
{
SendClientMessage(playerid,COLOR_ERROR,"#Error: You Muted.");
return 1;
}
if (!isNumeric(tmp))
{
TargetID = TargetID = ReturnUser(tmp, playerid);
if (TargetID == INVALID_PLAYER_ID)
{
return 1;
}
}
else
{
TargetID = strval(tmp);
if (!IsPlayerConnected(TargetID))
{
format(string, sizeof(string), "%d Is Not A Valid ID.", TargetID);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
}
id = strlen(tmp);
tmp = strtok(params, idx);
if (TargetID == playerid)
{
SendClientMessage(playerid, COLOR_ERROR, "You Cannot PM Yourself!");
return 1;
}
if (strmid(message, params, id + strlen(cmd) + 1, strlen(params), 256))
{
OnPlayerPrivmsg(playerid, TargetID, message);
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /pm (Name/Id) (message).");
}
return 1;
}
COMMAND:pm(playerid, params[])
{
new TargetID, message[128];
if(sscanf(params, "is[128]", TargetID, message)) return SendClientMessage(playerid, COLOR_ERROR, "USAGE: /pm (Name/Id) (message).");
if(PlayerInfo[playerid][pMuted] == 1) return SendClientMessage(playerid,COLOR_ERROR,"#Error: You Muted.");
if(TargetID == playerid) return SendClientMessage(playerid, COLOR_ERROR, "You Cannot PM Yourself!");
if(!IsPlayerConnected(TargetID))
{
format(string, sizeof(string), "%d Is Not A Valid ID.", TargetID);
SendClientMessage(playerid, -1, string);
return 1;
}
new value = strfind(message, "$loc", true);
if(value != -1)
{
strdel(message, value, value+4);
strins(message, PlayerInfo[playerid][pLocation], value);
}
OnPlayerPrivmsg(playerid, TargetID, message);
return 1;
}
zformat_replace(target[], specifier[], text[], size = sizeof target, bool:ignorecase = true)
{
new idx = -1, count;
while((idx = strfind(target, specifier, ignorecase)) != -1)
{
strdel(target, idx, idx + strlen(specifier));
strins(target, text, idx, size);
count ++;
}
return count;
}
new string[30] = "$name test string $name"; zformat_replace(string, "$name", PlayerName(playerid));
zformat_replace(string, "$loc", PlayerInfo[playerid][pLocation]); zformat_replace(string, "$me", PlayerInfo[playerid][pName]); SendClientMessageToAll(GetPlayerColor(playerid), string);
if(strcmp(string[idx], "$civ", true, 4) == 0)
{
new closeststr[100], closestplayer = GetCivWhoIsClosest(playerid);
if(IsPlayerConnected(closestplayer))
format(closeststr, sizeof(closeststr), "%s (%d)",PlayerInfo[closestplayer][pName],closestplayer);
else
format(closeststr, sizeof(closeststr), "%s (%d)",PlayerInfo[playerid][pName], playerid);
strdel(string, idx, idx + 4);
strins(string, closeststr, idx);
continue;
}
|
Ive tried using that zformat and can get the more simple strings like $me and $loc work inside individual commands by placing this between the string being formatted and the message being sent to players:
Код:
zformat_replace(string, "$loc", PlayerInfo[playerid][pLocation]); zformat_replace(string, "$me", PlayerInfo[playerid][pName]); SendClientMessageToAll(GetPlayerColor(playerid), string); Код:
if(strcmp(string[idx], "$civ", true, 4) == 0)
{
new closeststr[100], closestplayer = GetCivWhoIsClosest(playerid);
if(IsPlayerConnected(closestplayer))
format(closeststr, sizeof(closeststr), "%s (%d)",PlayerInfo[closestplayer][pName],closestplayer);
else
format(closeststr, sizeof(closeststr), "%s (%d)",PlayerInfo[playerid][pName], playerid);
strdel(string, idx, idx + 4);
strins(string, closeststr, idx);
continue;
}
|