Keep getting a invalid function or declaration error.
#1

Hello, I'm getting this error invalid function or declaration and I don't know what I'm doing wrong. i'm a new scripter so its probably an obvious mistake. Here is my code

pawn Код:
if (strcmp("/prison3277", cmdtext, true, 10) == 0) // This is a error line
    {
        SetPlayerPos(playerid, -1189.0684,-964.0616,129.2119);
        SendClientMessage(playerid, 0xFFFF40FF, "You have been Teleported");
        return 1; // This is a error line
        }
The error line and message: D:\user\Desktop\Raven's Roleplay 0.3c\filterscripts\testingteleport.pwn(103) : warning 217: loose indentation
D:\user\Desktop\Raven's Roleplay 0.3c\filterscripts\testingteleport.pwn(115) : error 010: invalid function or declaration
D:\user\Desktop\Raven's Roleplay 0.3c\filterscripts\testingteleport.pwn(119) : error 010: invalid function or declaration
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
Reply
#2

Could you please post your whole OnPlayerCommandText callback? If you're not comfortable with doing so here, you can private message me it.
Reply
#3

Is it under OnPlayerCommandText ?
Reply
#4

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp(cmdtext, "/cia", true) == 0)
    {

        if(IsPlayerAdmin(playerid))
        {

            SetPlayerPos(playerid, 100.7311,1920.8513,18.2811);
            SendClientMessage(playerid, 0xFFFF40FF, "You have been Teleported");
            SendClientMessage(playerid, -1, "You had been teleported");



         return 1;
        }
        else
        {
        SendClientMessage(playerid, -1, "You are not authorized to use this command.");
        return 1;
        }
    }
    return 0;
}

//==============================================================================
if (strcmp("/prison3277", cmdtext, true, 10) == 0)
    {
        SetPlayerPos(playerid, -1189.0684,-964.0616,129.2119);
        SendClientMessage(playerid, 0xFFFF40FF, "You have been Teleported");
        return 1;
        }
There you are bud.
Reply
#5

That's your problem, you need to actually include the code into a callback (for your case, the OnPlayerCommandText callback)
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp(cmdtext, "/cia", true) == 0)
    {

        if(IsPlayerAdmin(playerid))
        {

            SetPlayerPos(playerid, 100.7311,1920.8513,18.2811);
            SendClientMessage(playerid, 0xFFFF40FF, "You have been Teleported");
            SendClientMessage(playerid, -1, "You had been teleported");



         return 1;
        }
        else
        {
        SendClientMessage(playerid, -1, "You are not authorized to use this command.");
        return 1;
        }
    }

    if (strcmp("/prison3277", cmdtext, true, 10) == 0)
    {
        SetPlayerPos(playerid, -1189.0684,-964.0616,129.2119);
        SendClientMessage(playerid, 0xFFFF40FF, "You have been Teleported");
        return 1;
     }
    return 0;
}
I'd also suggest you indent the code properly. It makes it easier to lead and can prevent some errors in code (due to misreading).
Reply
#6

put return0; in the end of OnPlayerCommandText.
EDIT: Grim_ was faster :\.
Reply
#7

Thank you for your help guys. I'm still trying to study pawn and get use to it, so I'm going to be asking questions for a while Thanks for helping!
Reply
#8

No problem.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)