w00t ?
#1

I've tryed to make an "anti-repeat-myself" , but i fail ...

I don't like to use strfind , so i decied to use strcmp ...

# How this proceed:

If i type : hello ( then i press enter )

And after a second i type again , hello

He must send me that message : * Don't repeat yourself !


But he send me that message at the first hello ...



Code Here: http://pastebin.com/d23d09b60
Reply
#2

strmid and a player array like lastchat[playerid]

compare lastchat[playerid] with text in OnPlayerText
Reply
#3

so i can't use strcmp in a command ?
Reply
#4

bump
Reply
#5

bumping is the best way to make a topic disappear

I told you one method of doing it already. If anyone has more input, they'll post.
Reply
#6

oh sorry , but i didn't understand you

Could you like to make / post an example ?

Thanks
Reply
#7

okey , i've tryed , but now i don't recive the antispam message

http://pastebin.com/m49bbc559
Reply
#8

This is what I would do, I made a simple function to set a string so that you don't need to use string = string;, which will give you trouble if the target string is a different size.

pawn Код:
stock strset(source[],destination[])
{
    for(new i; i < strlen(source); i++)
    {
        destination[i] = source[i];
    }
}
Now this is what I would do for an anti-repeat in OnPlayerText:

pawn Код:
new LastSentance[MAX_PLAYERS][128]; //At top of script

public OnPlayerText(playerid,text[])
{
    if(strcmp(LastSentance[playerid],text,true) == 0)
    {
        SendClientMessage(playerid,red,"Please don't repeat yourself!");
        return 0;
    }
    strset(text,LastSentance[playerid]);
    return 1;
}
Reply
#9

oh , i don't want a antirepeatmyself in OnPlayerText

I want it in that command
Reply
#10

Quote:
Originally Posted by MJφ
oh , i don't want a antirepeatmyself in OnPlayerText

I want it in that command
Well its the same thing, just move it to a command..

Quote:
Originally Posted by JaTochNietDan
This is what I would do, I made a simple function to set a string so that you don't need to use string = string;, which will give you trouble if the target string is a different size.

pawn Код:
stock strset(source[],destination[])
{
    for(new i; i < strlen(source); i++)
    {
        destination[i] = source[i];
    }
}
Why not use format?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)