Strtok Error help
#1

C:\Users\A\Desktop\Server\Script\filterscripts\fur nituresys.pwn(487) : error 021: symbol already defined: "strtok"

How to fix this error? I tried much but didn't find a way.



PHP код:
    if(strcmp(cmd,"/Remove",true) == 0)
    {
        new 
tmp[128], idstring[256];
        
tmp strtok(cmdtextidx);
        if(!
strlen(tmp))
        { 
there is much like this, which means I made many commands with ''strtok''
Reply
#2

PHP код:
strtok(const string[], &index)
{
    new 
length strlen(string);
    while ((
index length) && (string[index] <= ' '))
    {
        
index++;
    }
 
    new 
offset index;
    new 
result[20];
    while ((
index length) && (string[index] > ' ') && ((index offset) < (sizeof(result) - 1)))
    {
        
result[index offset] = string[index];
        
index++;
    }
    
result[index offset] = EOS;
    return 
result;

Reply
#3

Still doesn't work.
Reply
#4

Create a stock for it..

PHP код:
stock strtok(const string[], &index)
{
    new 
length strlen(string);
    while ((
index length) && (string[index] <= ' '))
    {
        
index++;
    }
    new 
offset index;
    new 
result[20];
    while ((
index length) && (string[index] > ' ') && ((index offset) < (sizeof(result) - 1)))
    {
        
result[index offset] = string[index];
        
index++;
    }
    
result[index offset] = EOS;
    return 
result;

Reply
#5

mate when I add your code it gives me the same error, when I delete it, it works without any error.

BUT, the commands doesn't work
Reply
#6

Line 487, script fur nituresys.pwn
Reply
#7

You probably have defined it twice or if you haven't then show your whole OnPlayerCommandText. I suggest you using a command processor and sscanf for commands though. It would be easier and faster.

Quote:
Originally Posted by RyderX
Посмотреть сообщение
Create a stock for it..

PHP код:
stock strtok(const string[], &index)
{
    new 
length strlen(string);
    while ((
index length) && (string[index] <= ' '))
    {
        
index++;
    }
    new 
offset index;
    new 
result[20];
    while ((
index length) && (string[index] > ' ') && ((index offset) < (sizeof(result) - 1)))
    {
        
result[index offset] = string[index];
        
index++;
    }
    
result[index offset] = EOS;
    return 
result;

A function, not a stock! https://sampforum.blast.hk/showthread.php?tid=570635
Reply
#8

Quote:
Originally Posted by RyderX
Посмотреть сообщение
PHP код:
strtok(const string[], &index)
//CODE 
Код:
symbol already defined: "strtok"


OT: It means you have 'strtok' function defined more than once, Find the duplicated version and remove it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)