20.07.2009, 22:08
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
p.s. I know I know bad me, I used strtok :P
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");
}
}

