Issues with strings - 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: Issues with strings (
/showthread.php?tid=520953)
Issues with strings -
nmader - 21.06.2014
Hey guys, I'm updating my stranger system, and I ran into a bit of a blockade. How would I go above removing part of the string while inserting another part? What I have hear constantly inserts the information, but doesn't remove the old HP and such.
pawn Код:
if(StrangerID[playerid] > 0)
{
new Float:arm, Float:hps, healthstring[64];
GetPlayerHealth(playerid, hps);
GetPlayerArmour(playerid, arm);
new hpe = floatround(hps);
new arme = floatround(arm);
if(arm != 0)
{
format(healthstring, sizeof(healthstring), "\nHP: %d | Armour: %d", hpe, arme);
}
else
{
format(healthstring, sizeof(healthstring), "\nHealth: %d", hpe);
}
format(PlayerInfo[playerid][HealthString], 64, healthstring);
strcat(PlayerInfo[playerid][StrangerMask], healthstring, 256);
Update3DTextLabelText(StrangerTag[playerid], WHITE, PlayerInfo[playerid][StrangerMask]);
}
Re: Issues with strings -
Ciandlah - 21.06.2014
https://sampwiki.blast.hk/wiki/Strdel
then update the string with what you want
Re: Issues with strings -
Threshold - 21.06.2014
Can't you just:
pawn Код:
if(StrangerID[playerid])
{
new Float:arm, Float:hps, healthstring[64], string[128];
GetPlayerHealth(playerid, hps);
GetPlayerArmour(playerid, arm);
new var = floatround(hps), var2 = floatround(arm);
format(healthstring, sizeof(healthstring), (var2) ? ("\nHP: %d | Armour: %d") : ("\nHealth: %d"), (var2) ? (var, var2) : (var));
PlayerInfo[playerid][HealthString] = healthstring;
format(string, sizeof(string), "%s%s", PlayerInfo[playerid][StrangerMask], healthstring);
Update3DTextLabelText(StrangerTag[playerid], WHITE, string);
}
I don't know how big your 'StrangerMask' is, so I just used 128. (I'm assuming it's not 256 cells long...)
EDIT: This way, your 'PlayerInfo[playerid][StrangerMask]' never changes, and you won't need to delete anything from it.