A problem with strcpy. - 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: A problem with strcpy. (
/showthread.php?tid=489211)
A problem with strcpy. -
kristo - 21.01.2014
pawn Код:
CMD:majat2nav(playerid, p[])
{
if (KasutajaInfo[playerid][mAdmin] < 5) return SCM(playerid, COLOR_RED, "Sa pead selle kдskluse kasutamiseks olema vдhemalt administraator.");
new tanav[32];
if (sscanf(p, "s[32]", tanav)) return SCM(playerid, COLOR_WHITE, "KASUTUS: /majatдnav <Tдnavanimi ja majanumber>");
new vw = GetPlayerVW(playerid);
foreach (Houses, i)
{
if (IsPlayerInRangeOfPoint(playerid, 2, MajaInfo[i][mExtPos][0], MajaInfo[i][mExtPos][1], MajaInfo[i][mExtPos][2]) || (IsPlayerInRangeOfPoint(playerid, 2, MajaInfo[i][mIntPos][0], MajaInfo[i][mIntPos][1], MajaInfo[i][mIntPos][2]) && vw == MajaInfo[i][mVW]))
{
new vanatanav[32];
strcpy(vanatanav, MajaInfo[i][mTanav]);
strcpy(MajaInfo[i][mTanav], tanav);
UuendaMaja(i);
UuendaMajaLabel(i);
SFM(playerid, COLOR_WHITE, "Muutsid maja %s tдnavanimeks %s.", vanatanav, MajaInfo[i][mTanav]);
return 1;
}
}
return SCM(playerid, COLOR_RED, "Sa pole ьhegi maja ukse juures!");
}
I made this command months ago and i've been using it since then and it has always worked. Now, whatever i'm typing, I get "Muutsid maja (old name here if it isn't already blank) tдnavanimeks ." and the name disappears from the label. I haven't edited this code for a long time but I have upgraded my server to 0.3z (R2).
My strcpy (taken from Y_Utils, I guess):
pawn Код:
#define strcpy(%0,%1) strcat((%0[0] = '\0', %0), %1)
Re: A problem with strcpy. -
kristo - 21.01.2014
Bump.
Re: A problem with strcpy. -
kristo - 22.01.2014
Bump.
Re: A problem with strcpy. -
kristo - 22.01.2014
Fixed:
pawn Код:
#define safestrcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)