sscanf
#1

I have a problem with sscanf, it's working wrong.


Код:
YCMD:spec(playerid, params[], help)
{
   	if(sscanf(params, "u", params[0])) return SendClientMessage(playerid, COLOR_WHITE, "TYPE: /spec [id/name]");
	if(!IsPlayerConnected(params[0])) return SendClientMessage(playerid, COLOR_GREY, "The player isn't connected!");
       etc.
}
Sometimes sscanf returns


Код:
SendClientMessage(playerid, COLOR_GREY, "The player isn't connected!");
However the player is on the server. What's happend? How can I fix that?

Thx before.
Reply
#2

I wouldn't use the native params for that, but:
pawn Код:
YCMD:spec(playerid, params[], help)
{
    new iPlayer;
    if(sscanf(params, "u", iPlayer)) return SendClientMessage(playerid, COLOR_WHITE, "TYPE: /spec [id/name]");
    if(iPlayer == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "The player isn't connected!");
    //etc.
}
Reply
#3

Where can I get plugin sscanf for Fedora? Maybe it's not working because I'm using plugin not for Fedora.
Reply
#4

When it says an online player is not a valid player, it's due to the plugin's version. This happens with older versions, so update sscanf to the latest one.

https://sampforum.blast.hk/showthread.php?tid=120356
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
When it says an online player is not a valid player, it's due to the plugin's version. This happens with older versions, so update sscanf to the latest one.

https://sampforum.blast.hk/showthread.php?tid=120356
I used the latest version. The same shit.
Reply
#6

I've heard that a lot of times and always either the plugin file or the include was not updated.

So use it as Loot said in his post and make sure again that the sscanf version is 2.8.1 (the sscanf2.inc too).
Reply
#7

I think this sscanf plugin will work for you. Click me

use sscanf like this:

pawn Код:
YCMD:spec(playerid, params[], help)
{
    #pragma unused help
// Keep pragma unused help if you don't want to use the help thing y_commands have (or delete it if you do)
    new id; // The ID you will enter after /spec
    if(sscanf(params,"u",id)) SendClientMessage(playerid, -1, "Usage: /spec [id/name]");
    else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000FF, "Player is not connected.");
    else
    {
        // Do what you want here.
    }
    return 1;
}
Also, Read this, it tells you how sscanf works. Click me
Reply
#8

Quote:
Originally Posted by Stinged
Посмотреть сообщение
I think this sscanf plugin will work for you. Click me

use sscanf like this:

pawn Код:
YCMD:spec(playerid, params[], help)
{
    #pragma unused help
// Keep pragma unused help if you don't want to use the help thing y_commands have (or delete it if you do)
    new id; // The ID you will enter after /spec
    if(sscanf(params,"u",id)) SendClientMessage(playerid, -1, "Usage: /spec [id/name]");
    else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000FF, "Player is not connected.");
    else
    {
        // Do what you want here.
    }
    return 1;
}
Also, Read this, it tells you how sscanf works. Click me
I just did all commands like this but it still returns "Player isn't connected", plugin 2.8.1, include too.
Reply
#9

I use plugin 2.8.1, but somtimes sscanf doesn't find a player yet.

Help me please.
Reply
#10

Well, it works perfectly for me.
Since I script basic stuff, I use zcmd, it's more... simple.
Try the code I posted but with zcmd (Click me for link)

Note: Remove #pragma unused help when you try using zcmd.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)