gametext crashing - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: gametext crashing (
/showthread.php?tid=87549)
gametext crashing -
Annihalation - 20.07.2009
So I made a code for the business ownership part of my server, the code is called "/setentrysign".
the entrances are marked by fast-respawn pickups in my server, and when you walk over one, it displays the store's "entrysign" (as gametext)
so far, I have the entire thing working. The only problem is if someone uses a "~n~", or an underscore (_), the server crashes. Is there a way to make it to where it will refuse the input if the server finds a "~n~"?
however, I want to make it to where (for this particular code only), the server converts all _'s into spaces. Example would be "/setentrysign Pizza_Palace". When someone picked that up, they would get "Pizza Palace"
Heres the code for the command, and thanks in advance
Код:
if(strcmp(cmd, "/setentrysign", true)==0)
{
new tmp[128], interior;
tmp = strtok(cmdtext, idx);
interior = GetPlayerInterior(playerid);
if (strlen(tmp)==0) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /setentrysign <text>");
if (interior ==0) return SendClientMessage(playerid, 0xFF0000AA, "You must be inside a business you own to use this");
if (interior == 5)
{
new pname[24], cowner[256];
GetPlayerName(playerid, pname, sizeof(pname));
cowner = dini_Get("pizzaria.ini", "owner");
if (cowner = pname)
{
new string[256];
format(string, sizeof(string), "New Business Entry Sign: %s", tmp);
dini_Set("pizzaria.ini", "entrysign", tmp);
SendClientMessage(playerid, 0xFFFFFFFF, string);
}
else return SendClientMessage(playerid, 0xFF0000AA, "ERROR: You do not own this business");
}
}
p.s. I know I know bad me, I used strtok :P
Re: gametext crashing -
Blacklite - 21.07.2009
pawn Код:
if (strfind(tmp, "~n~", true) >= 0)
{
// invalid character, send evil error message here
}
Re: gametext crashing -
yezizhu - 21.07.2009
Just a guess:
dini uses en/uncode(), will it make something wrong?
Re: gametext crashing -
Blacklite - 21.07.2009
Actually, you shouldn't let the users put the ~ in text draws. Ever. So do this:
pawn Код:
if (strfind(tmp, "~", true) >= 0)
{
// invalid character, send evil error message here
}