SA-MP Forums Archive
Slap command returns an Unknown Command when player is not connected - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Slap command returns an Unknown Command when player is not connected (/showthread.php?tid=273059)



Login Issue - HydraX - 31.07.2011

It works! Thanks, now I got another issue!

pawn Code:
case DIALOG_LOGIN: //for loging
        {
            if(response)
            { //opening barrel
                new
                    strText[179], naslov2[128];
               
                if(strlen(inputtext) >= 4 && strlen(inputtext) <= 35)
                { //opening barrel
                    OnPlayerLogin(playerid, inputtext); //loading stats
                } //closing barrel
                else
                { //opening barrel
                    format(naslov2, sizeof(naslov2), ""COL_GREEN2"     Welcome"COL_WHITE" %s!", GetName(playerid)); //formating our title
                    format(strText, 179, ""COL_WHITE"______________________________\n\n"COL_GREEN2"Name"COL_WHITE" %s"COL_GREEN2" is registered!\n\n{F81414}You typed wrong password!", GetName(playerid)); //formating our text
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, naslov2, strText, "Login", "Exit");
                }
            }
            else Kick(playerid);
        }
    }
The Login code doesn't seem correct. I can type anything and still login.


Re: Slap command returns an Unknown Command when player is not connected - [HiC]TheKiller - 31.07.2011

pawn Code:
sscanf(params, "is[128]", playerid)
That has one single param, playerid. Your code should look more like

pawn Code:
sscanf(params, "i", playerid)
Also, for single params, you can just do this:

pawn Code:
playerid = strval(params);



Re: Slap command returns an Unknown Command when player is not connected - HydraX - 31.07.2011

Doesn't that return a "Strings without a length are deprecated" warning ?


Re: Slap command returns an Unknown Command when player is not connected - HydraX - 31.07.2011

BTW, When you type /slap 1, I get an Unknown Command, and not "Player not Connected".
Note That only ID 0 is connected.


Re: Slap command returns an Unknown Command when player is not connected - Runedog48 - 31.07.2011

Add a return 1; to the end of it and make the else statement...
pawn Code:
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 1)
    {
        if(sscanf(params, "is[128]", playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /slap [playerid]"); // Checking is the player just typed /slap now e.g. /slap 0 10
        if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "Player not connected");
        //else
        format(string, sizeof(string), "%s has slapped %s",pName,vName); // Defining string
        SendClientMessageToAll(COLOR_ORANGE, string);
        GetPlayerPos(playerid, x,y,z);
        SetPlayerPos(playerid,x,y,z+15);
//here return 1;
    }



Re: Slap command returns an Unknown Command when player is not connected - HydraX - 31.07.2011

Wait what? Where am I suppose to put it?


Re: Slap command returns an Unknown Command when player is not connected - HydraX - 31.07.2011

So Like this?
pawn Code:
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 1)
    {
        if(sscanf(params, "i", playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /slap [playerid]"); // Checking is the player just typed /slap now e.g. /slap 0 10
        if(IsPlayerConnected(playerid))
        {
            format(string, sizeof(string), "%s has slapped %s",pName,vName); // Defining string
            SendClientMessageToAll(COLOR_ORANGE, string);
            GetPlayerPos(playerid, x,y,z);
            SetPlayerPos(playerid,x,y,z+15);
            return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_ORANGE,"Player is not connected");
        }
    }
Now it won't show the "Player is not Connected" message.


Re: Slap command returns an Unknown Command when player is not connected - Jack_Leslie - 31.07.2011

pawn Code:
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 1)
    {
        if(sscanf(params, "i", playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /slap [playerid]"); // Checking is the player just typed /slap now e.g. /slap 0 10
        if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "Player is not connected");
            format(string, sizeof(string), "%s has slapped %s",pName,vName); // Defining string
            SendClientMessageToAll(COLOR_ORANGE, string);
            GetPlayerPos(playerid, x,y,z);
            SetPlayerPos(playerid,x,y,z+15);
            return 1;
    }
But I think you need to make a "giveplayerid" and make it so "giveplayerid" is the playerid that gets slapped? Otherwise the script is going to confuse it's self..


Re: Slap command returns an Unknown Command when player is not connected - HydraX - 31.07.2011

I don't get what you are saying.
I still need help! Now it doesn't return a Message when it should send "Player not connected"


Re: Slap command returns an Unknown Command when player is not connected - Toreno - 31.07.2011

Try this, looks perfect to me. HOWEVER, not tested.
Also, "i" parameter is an integer and "u" parameter represents User (bot/player) ...
BTW, do not update your SA-MP server to R5 until Y_Less fixes the "u" parameter, meanwhile, stay with R4 or lower.
pawn Code:
YCMD:slap(playerid, params[], help) {
    #pragma unused help
    new targetid, Float:x, Float:y, Float:z, slap_string[62];
    if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_ORANGE,"You are not a high enough level to use this command !");
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /slap [playerid]"); // "u" parameter is User (bot/player)
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_ORANGE, "Player not connected");
    format(slap_string, sizeof(slap_string), "%s has slapped %s", GetPlayerNameEx(playerid), GetPlayerNameEx(targetid));
    SendClientMessageToAll(COLOR_ORANGE, string);
    GetPlayerPos(targetid, x, y, z);
    SetPlayerPos(targetid, x, y, z+15);
    return 1;
}

stock GetPlayerNameEx(playerid) {
    new PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    return PlayerName;
}



Re: Slap command returns an Unknown Command when player is not connected - iPLEOMAX - 31.07.2011

I not a user of ycmd, but try this:

pawn Код:
YCMD:slap(playerid, params[], help)
{
    #pragma unused help
    new vName[MAX_PLAYER_NAME];
    new pName[MAX_PLAYER_NAME];
    new Float:x, Float:y, Float:z;
    new string[128];
    GetPlayerName(playerid,pName, 32);
    if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin] >= 1)
    {
        new rplayer;
        if(sscanf(params, "i", rplayer)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /slap [playerid]");
        if(!IsPlayerConnected(rplayer)) return SendClientMessage(playerid, COLOR_ORANGE, "Player not connected");
        GetPlayerName(rplayer,vName, 32);
        format(string, sizeof(string), "%s has slapped %s",pName,vName); // Defining string
        SendClientMessageToAll(COLOR_ORANGE, string);
        GetPlayerPos(playerid, x,y,z);
        SetPlayerPos(playerid,x,y,z+15);
    }
    else SendClientMessage(playerid, COLOR_ORANGE,"You are not a high enough level to use this command !");
    return 1;
}



Re: Slap command returns an Unknown Command when player is not connected - Toreno - 31.07.2011

Yours won't work aswell, because first... "u" parmeter is the correct parameters to use for PLAYERID.
Also, the SetPlayerPos() is still on playerid, which means who types the command itself.

My last post, I posted a good one, test it out.


Re: Slap command returns an Unknown Command when player is not connected - HydraX - 31.07.2011

It works! Thanks, now I got another issue!

pawn Код:
case DIALOG_LOGIN: //for loging
        {
            if(response)
            { //opening barrel
                new
                    strText[179], naslov2[128];
               
                if(strlen(inputtext) >= 4 && strlen(inputtext) <= 35)
                { //opening barrel
                    OnPlayerLogin(playerid, inputtext); //loading stats
                } //closing barrel
                else
                { //opening barrel
                    format(naslov2, sizeof(naslov2), ""COL_GREEN2"     Welcome"COL_WHITE" %s!", GetName(playerid)); //formating our title
                    format(strText, 179, ""COL_WHITE"______________________________\n\n"COL_GREEN2"Name"COL_WHITE" %s"COL_GREEN2" is registered!\n\n{F81414}You typed wrong password!", GetName(playerid)); //formating our text
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, naslov2, strText, "Login", "Exit");
                }
            }
            else Kick(playerid);
        }
    }
The Login code doesn't seem correct. I can type anything and still login.


Re: Slap command returns an Unknown Command when player is not connected - Toreno - 31.07.2011

Post your OnPlayerLogin public.


Re: Slap command returns an Unknown Command when player is not connected - HydraX - 01.08.2011

Quote:
Originally Posted by EliranPesahov
Посмотреть сообщение
Post your OnPlayerLogin public.
pawn Код:
OnPlayerLogin(playerid, password[])
{
    new
        hashPassword[129],
        uFile[35];

    format(uFile, 35, USER_FILE, GetName(playerid));
    INI_ParseFile(uFile, "LoadUserData", .bExtra = true, .extra = playerid);
    WP_Hash(hashPassword, 129, password);
    if(strcmp(PlayerInfo[playerid][pPassword], hashPassword, true))
    {
      SetPVarInt(playerid, "Logged", 1); //setting PVar that palyer is logged in
    }
    return 1;
}



Re: Slap command returns an Unknown Command when player is not connected - Toreno - 01.08.2011

Try these two.
pawn Код:
case DIALOG_LOGIN: {
    if(!response) return Kick(playerid);
    new
        strText[179], naslov2[128];

    if(!strlen(inputtext)) {
        format(naslov2, sizeof(naslov2), ""COL_GREEN2"     Welcome"COL_WHITE" %s!", GetName(playerid)); //formating our title
        format(strText, 179, ""COL_WHITE"______________________________\n\n"COL_GREEN2"Name"COL_WHITE" %s"COL_GREEN2" is registered!", GetName(playerid)); //formating our text
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, naslov2, strText, "Login", "Exit");
        return 1;
    }
    OnPlayerLogin(playerid, inputtext); //loading stats
}
pawn Код:
OnPlayerLogin(playerid, password[]) {
    new
        hashPassword[129], uFile[35];

    format(uFile, 35, USER_FILE, GetName(playerid));
    INI_ParseFile(uFile, "LoadUserData", .bExtra = true, .extra = playerid);
    WP_Hash(hashPassword, 129, password);
    if(!strcmp(PlayerInfo[playerid][pPassword], hashPassword, true)) {
        format(naslov2, sizeof(naslov2), ""COL_GREEN2"     Welcome"COL_WHITE" %s!", GetName(playerid)); //formating our title
        format(strText, 179, ""COL_WHITE"______________________________\n\n"COL_GREEN2"Name"COL_WHITE" %s"COL_GREEN2" is registered!\n\n{F81414}You typed wrong password!", GetName(playerid)); //formating our text
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, naslov2, strText, "Login", "Exit");
        return 1;
    }
    SetPVarInt(playerid, "Logged", 1); //setting PVar that palyer is logged in
    return 1;
}



Re: Slap command returns an Unknown Command when player is not connected - HydraX - 01.08.2011

Still doesn't fix the problem, I don't type anything above 4 characters and I still can login.