Commands only show USAGE - HELP REQUESTED
#1

There seems to be a problem with my commands which includes sscanf. Looking at this below, you can see it is a /goto command, which compiles perfectly in pawno.

But when I go ingame and try out the command. "Usage: /goto (ID)" is always shown on the screen. No matter what I do, it only shows the Usage. I tried all IDs, even IDs that are not online, and it only shows "Usage: /goto (ID)"



Код:
cmd(goto, playerid, params[])
{
	new targetid; new string[120];
	if(sscanf(params, "u", targetid))
		return SendClientMessage(playerid, COLOR_ERROR, "Usage: /goto (ID)");
	if(!IsPlayerConnected(targetid))
		return SendClientMessage(playerid, COLOR_ERROR, "Invalid ID.");
	format(string, 120, "You have teleported to %s", PlayerInfo(targetid));
	SendClientMessage(playerid, COLOR_ADMIN, string);
	new Float:x, Float:y, Float:z;
	GetPlayerPos(targetid, x, y, z);
	SetPlayerPos(playerid, x, y, z);
	SetPlayerInterior(playerid, GetPlayerInterior(targetid));
	return 1;
}
This happens with all other commands that uses this stupid sscanf eg.(/ban, /kick, /spec etc...) I have tried everything to stop this problem and nothing works.

Its almost like this is a command to show me the USAGE of the command -.-


ALSO in the samp-server.exe console, it says "sscanf error: System not initialised"
Reply
#2

Well first of all,the command text goes out of those brackets.Try this.
Код:
cmd:goto(playerid, params[])
{
	new targetid; new string[120];
	if(sscanf(params, "u", targetid))
		return SendClientMessage(playerid, COLOR_ERROR, "Usage: /goto (ID)");
	if(!IsPlayerConnected(targetid))
		return SendClientMessage(playerid, COLOR_ERROR, "Invalid ID.");
	format(string, 120, "You have teleported to %s", PlayerInfo(targetid));
	SendClientMessage(playerid, COLOR_ADMIN, string);
	new Float:x, Float:y, Float:z;
	GetPlayerPos(targetid, x, y, z);
	SetPlayerPos(playerid, x, y, z);
	SetPlayerInterior(playerid, GetPlayerInterior(targetid));
	return 1;
}
Reply
#3

It still doesnt work, I get the same error
Reply
#4

Quote:
Originally Posted by Sewayne
Посмотреть сообщение
It still doesnt work, I get the same error
Your code seems fine, I haven't found any error, but at least try this code
pawn Код:
CMD:goto(playerid, params[])
{
    new
        targetid, string[50], Float:Positions[3];

    if(sscanf(params, "u", targetid))
        return SendClientMessage(playerid, COLOR_ERROR, "Usage: /goto (ID)");

    if(!IsPlayerConnected(targetid))
        return SendClientMessage(playerid, COLOR_ERROR, "Invalid ID.");

    GetPlayerPos( targetid, Positions[0], Positions[1], Positions[2] ), SetPlayerPos( playerid, Positions[0], Positions[1], Positions[2] ),
    SetPlayerInterior( playerid, GetPlayerInterior(targetid) ), SetPlayerVirtualWorld( playerid, GetPlayerVirtualWorld(targetid) );

    format(string, sizeof(string), "You have teleported to %s", PlayerInfo(targetid));
    SendClientMessage(playerid, COLOR_ADMIN, string);
    return true;
}
Reply
#5

I think I know what the problem is you most likely have some callbacks being called before sscanf2 is included which is causing a problem with the hooking namely OnPlayerConnect() lets take a look at that callback in the sscanf2 include.

pawn Код:
public OnPlayerConnect(playerid)
{
    new
        name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    SSCANF_Join(playerid, name, IsPlayerNPC(playerid));
    if (SSCANF_gOPC)
    {
        /*#emit PUSH.S   playerid
        #emit PUSH.C   4
        #emit LCTRL    6
        #emit ADD.C    28
        #emit PUSH.pri
        #emit LOAD.pri SSCANF_gOPC
        #emit SCTRL    6
        #emit RETN*/

        return CallLocalFunction("SSCANF_OnPlayerConnect", "i", playerid);
    }
    return 1;
}
What we can see here is to continue hooking through functions you get this line in the hooked callback
pawn Код:
return CallLocalFunction("SSCANF_OnPlayerConnect", "i", playerid);
It's likely you have some other include with OnPlayerConnect() being called before sscanf() which is breaking the hooking you can easily check this by editing the sscanf2.inc include file and putting in the line below.

pawn Код:
printf("SSCANF2::OnPlayerConnectCalled id: %i", playerid);
It's just a hunch give it a shot and let me know if you see that line print when you connect.
Reply
#6

Try simply downloading the latest sscanf plugin and replacing it with the current one.
Then recompile your script and try again.
Reply
#7

Quote:
Originally Posted by Tagathron
Посмотреть сообщение
Try simply downloading the latest sscanf plugin and replacing it with the current one.
Then recompile your script and try again.
Even if he doesn't have the latest that isn't the problem.
Reply
#8

Let me try
Reply
#9

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
Even if he doesn't have the latest that isn't the problem.
I had a problem like this with sscanf,where the code was correct but in game it always sent a message "USAGE:...." .
So when i got the plugin again and replaced it,the code worked.
Reply
#10

I found the answer to the problem, I downloaded the latest version of sscanf2 and it worked, although I tried it before and it didn't work which is strange. Thanks for the help guys
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)