About inputtext - 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: About inputtext (
/showthread.php?tid=544814)
About inputtext -
Metroplex - 04.11.2014
pawn Код:
FactionTag[GetPlayerFactionID(playerid)] = inputtext;
Код:
error 047: array sizes do not match, or destination array is too small
What the actual fuck is wrong with that fucking code? I fucking spent for a fucking hour already.
pawn Код:
//array sizes almost same
FactionTag[MAX_GROUPS][10],
Re: About inputtext -
DavidBilla - 04.11.2014
pawn Код:
format(FactionTag[GetPlayerFactionID(playerid)],sizeof(FactionTag[GetPlayerFactionID(playerid)]),"%s",inputtext);
Re: About inputtext -
Metroplex - 04.11.2014
C:\Documents and Settings\eros\Desktop\SA-MP Server\gamemodes\groupsystem.pwn(513) : error 001: expected token: "]", but found "-identifier-"
C:\Documents and Settings\eros\Desktop\SA-MP Server\gamemodes\groupsystem.pwn(513) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\eros\Desktop\SA-MP Server\gamemodes\groupsystem.pwn(513) : error 029: invalid expression, assumed zero
C:\Documents and Settings\eros\Desktop\SA-MP Server\gamemodes\groupsystem.pwn(513) : fatal error 107: too many error messages on one line
Re: About inputtext -
Vince - 04.11.2014
You can't assign a string in this manner in Pawn. For all you know, someone inputs "MyVeryLongTag". This is obviously longer than 10 characters. Then what?
Quote:
Originally Posted by DavidBilla
pawn Код:
format(FactionTag[GetPlayerFactionID(playerid)],sizeof(FactionTag[GetPlayerFactionID(playerid)]),"%s",inputtext);
|
Don't use format to copy strings, use strcat or strcpy.
Re: About inputtext -
Runn3R - 04.11.2014
Quote:
Originally Posted by Vince
I put this into the string.inc library:
pawn Код:
/* native strcpy(dest[], const source[], maxlength=sizeof dest); */
Function:
pawn Код:
stock strcpy(dest[], const source[], maxlength=sizeof dest) { strcat((dest[0] = EOS, dest), source, maxlength); }
|
Use it.