"Player not connected" if inserting an id cmd.
#1

I have this problem in my server, that if you insert an cmd, where you need to insert someone's id,
then it says "Player is not connected". It does that with admin cmds, e.g: /gethere, /goto.
Or even with regular cmds, e.g: /pm.

Please help!
Reply
#2

pawn Код:
if(!IsPlayerConnected(VarID)) return SendClientMessage(playerid, -1, "Syntax Error: Player Not Connected!");
In "VarID", your var for other playerid.
Reply
#3

Nope, now it says "Syntax Error: Player Not Connected!" in the server.

Help!

//edit: btw this worked on my other server, but not here
Reply
#4

Quote:
Originally Posted by kaiks
Посмотреть сообщение
Nope, now it says "Syntax Error: Player Not Connected!" in the server.

Help!

//edit: btw this worked on my other server, but not here
Look, if you are using Sscanf just try updating it with the latest version.
Reply
#5

Sigh.
1. What is your cmd processor?
2. Where the heck is your code?
Reply
#6

pawn Код:
if (!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "SERVER: This player is not connected."); // "!" = false, "!IsPlayerConnected(targetid) = If player is not connected. "targetid" = the one you are using the command on.

Put that on all your commands.
Should work.
Reply
#7

Wicked, i defined targetid as "[MAX_PLAYER_NAME]" and i get this:
"error 035: argument type mismatch (argument 1)"

Here's the code:
Код:
COMMAND:es(playerid,params[])
{
        new pid; //the player(id) defined
        new message[128]; //the string for the main-message
        new targetid[MAX_PLAYER_NAME];
		if(sscanf(params, "us[32]", pid, message)) //detects the wrong parameters, and if wrong, shows the usage
        {
            return SendClientMessage(playerid, COLOR_GREY, "Kasutus: /es [id] [tekst]");//displays the usage, if parameters are wrong
        }
        if (!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "SERVER: This player is not connected."); // "!" = false, "!IsPlayerConnected(targetid) = If player is not connected. "targetid" = the one you are using the command on.

        new pmsg[256]; //the message for player 1
        new pname[MAX_PLAYER_NAME]; // the name of player 1
        GetPlayerName(playerid,pname,sizeof(pname)); //get (receive the info) of the player's name
        format(pmsg,sizeof(pmsg),"(( -> %s(ID: %d) Erasхnum: %s ))",pname,playerid,message); //this will receive the message from the player, with the first message-string

        new pidmsg[256]; //the message for player 2
        new pidname[MAX_PLAYER_NAME];
		GetPlayerName(pid,pidname,sizeof(pidname)); //get (receive the info) of the player's name
        format(pidmsg,sizeof(pidmsg),"(( <- Erasхnum %s(ID: %d): %s ))",pidname,pid,message); //this will let the player know, that he has sent successfully a message to his destination
        SendClientMessage(pid, COLOR_ORANGE, pmsg); //the message for player 1 should appear in orange, the first message-string is used here
        PlayerPlaySound(pid,1057,0.0,0.0,0.0); //play a "success-sound"
        SendClientMessage(playerid, COLOR_ORANGE, pidmsg); //the message for player 2 should also appear in orange, the second message-string is used here

		return 1;
}
Reply
#8

Should work now:

pawn Код:
COMMAND:es(playerid,params[])
{
    new pid; //the player(id) defined
    new message[128]; //the string for the main-message
    if(sscanf(params, "us[32]", pid, message)) //detects the wrong parameters, and if wrong, shows the usage
    {
        return SendClientMessage(playerid, COLOR_GREY, "Kasutus: /es [id] [tekst]");//displays the usage, if parameters are wrong
    }
    if (!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOR_GREY, "SERVER: This player is not connected."); // "!" = false, "!IsPlayerConnected(pid) = If player is not connected. "pid" = the one you are using the command on.

    new pmsg[256]; //the message for player 1
    new pname[MAX_PLAYER_NAME]; // the name of player 1
    GetPlayerName(playerid,pname,sizeof(pname)); //get (receive the info) of the player's name
    format(pmsg,sizeof(pmsg),"(( -> %s(ID: %d) Erasхnum: %s ))",pname,playerid,message); //this will receive the message from the player, with the first message-string

    new pidmsg[256]; //the message for player 2
    new pidname[MAX_PLAYER_NAME];
    GetPlayerName(pid,pidname,sizeof(pidname)); //get (receive the info) of the player's name
    format(pidmsg,sizeof(pidmsg),"(( <- Erasхnum %s(ID: %d): %s ))",pidname,pid,message); //this will let the player know, that he has sent successfully a message to his destination
    SendClientMessage(pid, COLOR_ORANGE, pmsg); //the message for player 1 should appear in orange, the first message-string is used here
    PlayerPlaySound(pid,1057,0.0,0.0,0.0); //play a "success-sound"
    SendClientMessage(playerid, COLOR_ORANGE, pidmsg); //the message for player 2 should also appear in orange, the second message-string is used here
    return 1;
}
You defined targetid as a string, and it wasn't being used as a string, but an integer. Replaced everything with targetid to pid.
Reply
#9

Quote:
Originally Posted by kaiks
Посмотреть сообщение
Wicked, i defined targetid as "[MAX_PLAYER_NAME]" and i get this:
"error 035: argument type mismatch (argument 1)"

Here's the code:
Код:
COMMAND:es(playerid,params[])
{
        new pid; //the player(id) defined
        new message[128]
        new targetid;
		if(sscanf(params, "us[32]", pid, message)) //detects the wrong parameters, and if wrong, shows the usage
        {
            return SendClientMessage(playerid, COLOR_GREY, "Kasutus: /es [id] [tekst]");//displays the usage, if parameters are wrong
        }
        if (!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "SERVER: This player is not connected."); // "!" = false, "!IsPlayerConnected(targetid) = If player is not connected. "targetid" = the one you are using the command on.

        new pmsg[256]; //the message for player 1
        new pname[MAX_PLAYER_NAME]; // the name of player 1
        GetPlayerName(playerid,pname,sizeof(pname)); //get (receive the info) of the player's name
        format(pmsg,sizeof(pmsg),"(( -> %s(ID: %d) Erasхnum: %s ))",pname,playerid,message); //this will receive the message from the player, with the first message-string

        new pidmsg[256]; //the message for player 2
        new pidname[MAX_PLAYER_NAME];
		GetPlayerName(pid,pidname,sizeof(pidname)); //get (receive the info) of the player's name
        format(pidmsg,sizeof(pidmsg),"(( <- Erasхnum %s(ID: %d): %s ))",pidname,pid,message); //this will let the player know, that he has sent successfully a message to his destination
        SendClientMessage(pid, COLOR_ORANGE, pmsg); //the message for player 1 should appear in orange, the first message-string is used here
        PlayerPlaySound(pid,1057,0.0,0.0,0.0); //play a "success-sound"
        SendClientMessage(playerid, COLOR_ORANGE, pidmsg); //the message for player 2 should also appear in orange, the second message-string is used here

		return 1;
}
Don't define the "targetid". I've changed the code for you.

pawn Код:
COMMAND:es(playerid,params[])
{
        new message[128], pid, targetid;
        if(sscanf(params, "us[32]", pid, message)) //detects the wrong parameters, and if wrong, shows the usage
        {
            return SendClientMessage(playerid, COLOR_GREY, "Kasutus: /es [id] [tekst]");//displays the usage, if parameters are wrong
        }
        if (!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "SERVER: This player is not connected."); // "!" = false, "!IsPlayerConnected(targetid) = If player is not connected. "targetid" = the one you are using the command on.

        new pmsg[256]; //the message for player 1
        new pname[MAX_PLAYER_NAME]; // the name of player 1
        GetPlayerName(playerid,pname,sizeof(pname)); //get (receive the info) of the player's name
        format(pmsg,sizeof(pmsg),"(( -> %s(ID: %d) Erasхnum: %s ))",pname,playerid,message); //this will receive the message from the player, with the first message-string

        new pidmsg[256]; //the message for player 2
        new pidname[MAX_PLAYER_NAME];
        GetPlayerName(pid,pidname,sizeof(pidname)); //get (receive the info) of the player's name
        format(pidmsg,sizeof(pidmsg),"(( <- Erasхnum %s(ID: %d): %s ))",pidname,pid,message); //this will let the player know, that he has sent successfully a message to his destination
        SendClientMessage(pid, COLOR_ORANGE, pmsg); //the message for player 1 should appear in orange, the first message-string is used here
        PlayerPlaySound(pid,1057,0.0,0.0,0.0); //play a "success-sound"
        SendClientMessage(playerid, COLOR_ORANGE, pidmsg); //the message for player 2 should also appear in orange, the second message-string is used here

        return 1;
}
Reply
#10

Quote:
Originally Posted by .Wicked
Посмотреть сообщение
Don't define the "targetid". I've changed the code for you.

pawn Код:
COMMAND:es(playerid,params[])
{
        new message[128], pid, targetid;
        if(sscanf(params, "us[32]", pid, message)) //detects the wrong parameters, and if wrong, shows the usage
        {
            return SendClientMessage(playerid, COLOR_GREY, "Kasutus: /es [id] [tekst]");//displays the usage, if parameters are wrong
        }
        if (!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_GREY, "SERVER: This player is not connected."); // "!" = false, "!IsPlayerConnected(targetid) = If player is not connected. "targetid" = the one you are using the command on.

        new pmsg[256]; //the message for player 1
        new pname[MAX_PLAYER_NAME]; // the name of player 1
        GetPlayerName(playerid,pname,sizeof(pname)); //get (receive the info) of the player's name
        format(pmsg,sizeof(pmsg),"(( -> %s(ID: %d) Erasхnum: %s ))",pname,playerid,message); //this will receive the message from the player, with the first message-string

        new pidmsg[256]; //the message for player 2
        new pidname[MAX_PLAYER_NAME];
        GetPlayerName(pid,pidname,sizeof(pidname)); //get (receive the info) of the player's name
        format(pidmsg,sizeof(pidmsg),"(( <- Erasхnum %s(ID: %d): %s ))",pidname,pid,message); //this will let the player know, that he has sent successfully a message to his destination
        SendClientMessage(pid, COLOR_ORANGE, pmsg); //the message for player 1 should appear in orange, the first message-string is used here
        PlayerPlaySound(pid,1057,0.0,0.0,0.0); //play a "success-sound"
        SendClientMessage(playerid, COLOR_ORANGE, pidmsg); //the message for player 2 should also appear in orange, the second message-string is used here

        return 1;
}
Your's wouldn't even work. Targetid is a useless variable, since pid is already made. Plus, even if the ID was incorrect, It would probably still work, since targetid is a random variable and the script doesn't know that it is a playerid.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)