if(dialogid == HOUSEMENU+14)
{
if(response)
{
if(strfind(inputtext, "%", CASE_SENSETIVE) != -1 || strfind(inputtext, "~", CASE_SENSETIVE) != -1) return ShowInfoBoxEx(playerid, COLOUR_SYSTEM, E_INVALID_HNAME_CHARS);
if(strlen(inputtext) < MIN_HOUSE_NAME || strlen(inputtext) > MAX_HOUSE_NAME) return ShowInfoBoxEx(playerid, COLOUR_SYSTEM, E_INVALID_HNAME_LENGTH);
else
{
strreplace("admin","dick",inputtext);
format(hInfo[h][HouseName], MAX_HOUSE_NAME, "%s", inputtext);
file = INI_Open(filename);
INI_WriteString(file, "HouseName", inputtext);
INI_Close(file);
ShowInfoBox(playerid, I_HNAME_CHANGED, inputtext);
UpdateHouseText(h);
}
}
return 1;
}
strreplace(inputtext, "admin","dick");
if(strfind(inputtext == "Admin"))
{
strreplace(inputtext, "Dick");
return 1;
}
Try something like this:
pawn Код:
|
if(strfind(inputtext,"admin",true)!=-1)
{
new adpoz = strfind(inputtext,"admin",true);
strdel(inputtext,adpoz,adpoz+5);
strins(inputtext,"dick",adpoz,strlen(inputtext));
}
stock ret_memcpy(source[],index=0,numbytes)
{
new tmp[200];
new i=0;
tmp[0]=0;
if (index>=strlen(source)) return tmp;
if (numbytes+index>=strlen(source)) numbytes=strlen(source)-index;
if (numbytes<=0) return tmp;
for (i=index;i<numbytes+index;i++) {
tmp[i-index]=source[i];
if (source[i]==0) return tmp;
}
tmp[numbytes]=0;
return tmp;
}
stock strreplace(trg[],newstr[],src[])
{
new f=0;
new s1[128];
new tmp[128];
format(s1,sizeof(s1),"%s",src);
f = strfind(s1,trg,true);
tmp[0]=0;
while (f>=0) {
strcat(tmp,ret_memcpy(s1, 0, f));
strcat(tmp,newstr);
format(s1,sizeof(s1),"%s",ret_memcpy(s1, f+strlen(trg), strlen(s1)-f));
f = strfind(s1,trg);
}
strcat(tmp,s1);
return tmp;
}