Quick Strings... Help - 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)
+--- Thread: Quick Strings... Help (
/showthread.php?tid=557938)
Quick Strings... Help -
danish007 - 15.01.2015
Hello, i've Quick Strings Code, i want to make this code in one stock.
like we use stock somecode(.... .... ... ... ....)
pawn Код:
new
idx = strfind(text, "$");
if(idx != -1)
{
new
string[144];
strcat(string, text);
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);
continue;
}
else
if(strcmp(string[idx], "$cash", true, 5) == 0)
{
new pmoney[70];
format(pmoney, sizeof(pmoney), "$%d",GetPlayerCash(playerid));
strdel(string, idx, idx + 5);
strins(string, pmoney, idx);
continue;
}
else
if(strcmp(string[idx], "$ply", true, 4) == 0)
{
new closeststr[100], closestplayer = GetPlayerWhoIsClosest(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;
}
}
while((idx = strfind(string, "$", false, idx + 1)) != -1);
SendPlayerMessageToAll(playerid, string);
return 0;
}
i want to use it unde OnPlayerText.. and on my private message code
please help me
Re: Quick Strings... Help -
xVIP3Rx - 15.01.2015
here
pawn Код:
stock BlaBla(playerid, text)
{
new idx = strfind(text, "$");
if(idx != -1)
{
new string[144];
strcat(string, text);
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);
continue;
}
else
if(strcmp(string[idx], "$cash", true, 5) == 0)
{
new pmoney[70];
format(pmoney, sizeof(pmoney), "$%d",GetPlayerCash(playerid));
strdel(string, idx, idx + 5);
strins(string, pmoney, idx);
continue;
}
else
if(strcmp(string[idx], "$ply", true, 4) == 0)
{
new closeststr[100], closestplayer = GetPlayerWhoIsClosest(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;
}
}
while((idx = strfind(string, "$", false, idx + 1)) != -1);
SendPlayerMessageToAll(playerid, string);
}
return 1;
}
Rename "BlaBla" and use it like