Hello There, Guest! Login or Register


okay this is simple, but I'm freaking out on this one..
#1
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256];
    new idx;
if(strcmp(cmdtext, "/kill", true) == 0)
{
SetPlayerHealth(playerid, 0);
GivePlayerMoney(playerid, -0);
    return 1;
}

{
if(strcmp(cmdtext,"/help", true)==0)
{
SendClientMessage(playerid,COLOR_YELLOW,"/bla || Balance Test ");
SendClientMessage(playerid,COLOR_YELLOW,"/range || Shooting range");
SendClientMessage(playerid,COLOR_YELLOW,"/back || Airstrip");
}
{
if(strcmp(cmdtext,"/bla",true)==0)
        {
                SetPlayerInterior(playerid, 0);
                SetPlayerPos(playerid,2149.0371,-1805.6539,16.1464);
                SendClientMessage(playerid,COLOR_GREEN,"|==============|");
                SendClientMessage(playerid,COLOR_YELLOW,"| Balance Test |");
                SendClientMessage(playerid,COLOR_GREEN,"|==============|");
}
{
if(strcmp(cmdtext,"/range",true)==0)
        {
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid,794.8486, 1686.9917, 5.2813,273);
SendClientMessage(playerid,COLOR_GREEN,"|================|");
SendClientMessage(playerid,COLOR_YELLOW,"| Shooting Range |");
SendClientMessage(playerid,COLOR_GREEN,"|================|");
}
{
if(strcmp(cmdtext,"/back",true)==0)
        {
                SetPlayerInterior(playerid, 0);
                SetPlayerPos(playerid,413.3407,2531.4670,19.1658);
                SendClientMessage(playerid,COLOR_GREEN,"|=========|");
                SendClientMessage(playerid,COLOR_YELLOW,"| Airbase |");
                SendClientMessage(playerid,COLOR_GREEN,"|=========|");

return 1;
}


#define strtok

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; //result
}


Errors


C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(243) : warning 217: loose indentation
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(294) : warning 217: loose indentation
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(348) : warning 217: loose indentation
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(521) : warning 209: function "OnPlayerCommandText" should return a value
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(524) : warning 217: loose indentation
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(531) : warning 217: loose indentation
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(540) : warning 217: loose indentation
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(544) : warning 202: number of arguments does not match definition
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(549) : warning 217: loose indentation
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(558) : warning 217: loose indentation
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(558) : error 078: function uses both "return" and "return <value>"
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(558) : error 079: inconsistent return types (array & non-array)
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(564) : error 029: invalid expression, assumed zero
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(564) : error 017: undefined symbol "index"
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(564) : error 029: invalid expression, assumed zero
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(564) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


6 Errors.


So basicly I need help with strtok, because thats the big problem here.


EDIT:please Jay? O-)
Reply
#2
Next time use bin.sa-mp.nl as i cannot see any of that properly..
Right now i can only notice that you haven't returned 0 after at the end of the commands.

edit:
I also noticed you haven't returned or closed some of the commands....
Reply
#3
Code:
Try reading the warnings/errors.


[code]C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(243) : warning 217: loose indentation

Indent your code, or suppress the warnings (not recommended).

Code:
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(521) : warning 209: function "OnPlayerCommandText" should return a value

Return a value at the end of the callback, best to return 0.

Code:
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(544) : warning 202: number of arguments does not match definition

Check over your function, make sure all the parameters are correct & stated.

Code:
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(558) : error 078: function uses both "return" and "return <value>"

Your using return more than once.
Code:
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(558) : error 079: inconsistent return types (array & non-array)

^^


Code:
C:\Documents and Settings\ÄGARE\Skrivbord\bodyguards.pwn(564) : error 017: undefined symbol "index"

Define index.

The problem isn't so much with the way you are using strtok, just some simple mistakes :)



[u]EDIT:

Meh, since you said please:

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
//    new cmd[256];
//  new idx;
    //Commented out because you havnt used them here.
       if(strcmp(cmdtext, "/kill", true) == 0)
       {
        SetPlayerHealth(playerid, 0);
        GivePlayerMoney(playerid, -0);
        return 1;
    }


    if(strcmp(cmdtext,"/help", true)==0)
    {
        SendClientMessage(playerid,COLOR_YELLOW,"/bla || Balance Test ");
        SendClientMessage(playerid,COLOR_YELLOW,"/range || Shooting range");
        SendClientMessage(playerid,COLOR_YELLOW,"/back || Airstrip");
        return true; //You missed a return statement here.
    }

    if(strcmp(cmdtext,"/bla",true)==0)
    {
          SetPlayerInterior(playerid, 0);
        SetPlayerPos(playerid,2149.0371,-1805.6539,16.1464);
         SendClientMessage(playerid,COLOR_GREEN,"|==============|");
          SendClientMessage(playerid,COLOR_YELLOW,"| Balance Test |");
           SendClientMessage(playerid,COLOR_GREEN,"|==============|");
           return true; //Again, you missed a return statement. Note: true is the same as 1.
    }
//{ //What is this brace for?

    if(strcmp(cmdtext,"/range",true)==0)
    {
        SetPlayerInterior(playerid, 0);
        SetPlayerPos(playerid, 794.8486, 1686.9917, 5.2813); //You has a typo here, a comma instead of a decimal point!
        SendClientMessage(playerid,COLOR_GREEN,"|================|");
        SendClientMessage(playerid,COLOR_YELLOW,"| Shooting Range |");
        SendClientMessage(playerid,COLOR_GREEN,"|================|");
        return true; //No return statement again.
    }
//{Again with the the braces.
    if(strcmp(cmdtext,"/back",true)==0)
    {
          SetPlayerInterior(playerid, 0);
        SetPlayerPos(playerid,413.3407,2531.4670,19.1658);
         SendClientMessage(playerid,COLOR_GREEN,"|=========|");
          SendClientMessage(playerid,COLOR_YELLOW,"| Airbase |");
           SendClientMessage(playerid,COLOR_GREEN,"|=========|");
        return true; //Missing brace and return statement here.
    }

    return false;
}

//Why did you define strtok with no value?





/*

Since you are not using strtok atm, commented out.

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; //result
}
    
*/

That should work, try reading the comments for some tips in future :) Disregard the awful indention in code, when you copy and paste it into pawn it should be alright.[/code]
Reply
#4
I don't know what to say! yay Jay!  :>

no, but seriously, thanks!  :) I though I would go nuts about those errors  7(8)7 .. it's easy to get blind while using pawno i guess.  _O-


Thanks!
:w
Reply