SA-MP Forums Archive
What's wrong here.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: What's wrong here.. (/showthread.php?tid=478627)



What's wrong here.. - Bost - 30.11.2013

I made this:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/help", true))
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "To be updated.");
        return 1;
        // Returning 1 informs the server that the command has been processed.
        // OnPlayerCommandText won't be called in other scripts.
    }
    return 0;
    // Returning 0 informs the server that the command hasn't been processed by this script.
    // OnPlayerCommandText will be called in other scripts until one returns 1.
    // If no scripts return 1, the 'SERVER: Unknown Command' message will be shown.
}

if(!strcmp(cmdtext, "/help", true))
{
	if(IsPlayerConnected(playerid))
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "To be updated.");
	}
 	return 1;
}
And I get this errors:
Код:
F:\Jocuri, programe\Game-Mode\samp03x_svr_R2_win32\gamemodes\game.pwn(97) : error 010: invalid function or declaration
F:\Games\Game-Mode\....\gamemodes\game.pwn(99) : error 010: invalid function or declaration
F:\Games\Game-Mode\....\gamemodes\game.pwn(103) : error 010: invalid function or declaration
What to do?


Re: What's wrong here.. - Konstantinos - 30.11.2013

Any code out of callbacks is invalid. You already got the command /help so a double one is really pointless. It's also pointless to check if the playerid is connected player because if the player was not, then the callback would not even get called.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/help", true))
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "To be updated.");
        return 1;
    }
    return 0;
}



Re: What's wrong here.. - Bost - 30.11.2013

Код:
	if(!strcmp(cmdtext, "/make", true))
	{
		SendClientMessage(playerid, 0xFFFFFFFF, "To be updated.");
	}
 	return 1;
}
Did this, but I still get those:

Код:
F:\.....\Game-Mode\....\gamemodes\game.pwn(97) : error 010: invalid function or declaration
F:\....\Game-Mode\....\gamemodes\game.pwn(101) : error 010: invalid function or declaration



Re: What's wrong here.. - Konstantinos - 30.11.2013

Post lines 95-105.


Re: What's wrong here.. - Bost - 30.11.2013

Код:
}

	if(!strcmp(cmdtext, "/make", true))
	{
		SendClientMessage(playerid, 0xFFFFFFFF, "To be updated.");
	}
 	return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{



Re: What's wrong here.. - Konstantinos - 30.11.2013

I told you any code out of callbacks is invalid and you re-added outside.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/help", true))
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "To be updated.");
        return 1;
    }
    // other commands
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    // code..
    return 1;
}



Re: What's wrong here.. - Bost - 30.11.2013

Thanks, solved.


Re: What's wrong here.. - Mitchy - 30.11.2013

Like @Konstantinos said: Any command performed outside of a callback using strcmp will -not- work. If you don't want to have all of your commands inside a callback then try using command processors such as Z-CMD or Y-CMD.

P.S: strcmp commands are archaic.