SA-MP Forums Archive
Command help let's player do when other's not conencted - 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: Command help let's player do when other's not conencted (/showthread.php?tid=388611)



Command help let's player do when other's not conencted - jueix - 29.10.2012

ok, This command let's player's do when other player is not connected

pawn Код:
COMMAND:setint(playerid, params[])
{
    new id;
    new interior;
    if(IsPlayerConnected(id))
    {
        if(PlayerInfo[playerid][AdminLevel] >= 1)
        {
            if(!sscanf(params, "ui", id, interior))
            {
                if(interior <= 100)
                {
                    new string[64];
                    new name[MAX_PLAYER_NAME], PName[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, name, sizeof(name));
                    GetPlayerName(id, PName, sizeof(PName));
                    format(string, sizeof(string), "Your Interior Has Been Setted To %d By %s.", interior, name);
                    SendClientMessage(id, 0xD8D8D8FF, string);
                    format(string, sizeof(string), "You Setted %s Interior To %d.", PName, interior);
                    SendClientMessage(playerid, 0xD8D8D8FF, string);
                    SetPlayerInterior(id, interior);
                    return 1;
                }
                else return SendClientMessage(playerid, 0xD8D8D8FF, "Invalid Interior Id");
            }
            else return SendClientMessage(playerid, 0xD8D8D8FF, "USAGE: /setint [PlayerId/PartOfName] [Interior]");
        }
        else return SendClientMessage(playerid, 0xD8D8D8FF, "You are not allowed to use this command.");
    }
    else return SendClientMessage(playerid, 0xD8D8D8FF, "Player is not connected.");
}
help please.


Re: Command help let's player do when other's not conencted - Vince - 29.10.2012

Sigh. You can't expect to ever be a good coder if you cannot think logically. When a variable is initialized, its value is 0. What do you think will happen when the code reaches that first check?


Re: Command help let's player do when other's not conencted - [D]ry[D]esert - 29.10.2012

removed


Re: Command help let's player do when other's not conencted - ryansheilds - 29.10.2012

pawn Код:
COMMAND:setint(playerid, params[])
{
    new id;
    new interior;
    if(PlayerInfo[playerid][AdminLevel] >= 1)
    {
        if(!sscanf(params, "ui", id, interior))
        {
            if(IsPlayerConnected(id))
            {
                if(interior <= 100)
                {
                    new string[64];
                    new name[MAX_PLAYER_NAME], PName[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, name, sizeof(name));
                    GetPlayerName(id, PName, sizeof(PName));
                    format(string, sizeof(string), "Your Interior Has Been Setted To %d By %s.", interior, name);
                    SendClientMessage(id, 0xD8D8D8FF, string);
                    format(string, sizeof(string), "You Setted %s Interior To %d.", PName, interior);
                    SendClientMessage(playerid, 0xD8D8D8FF, string);
                    SetPlayerInterior(id, interior);
                    return 1;
                }
                else return SendClientMessage(playerid, 0xD8D8D8FF, "Invalid Interior Id");
            }
            else return SendClientMessage(playerid, 0xD8D8D8FF, "Player is not connected.");
        }
        else return SendClientMessage(playerid, 0xD8D8D8FF, "USAGE: /setint [PlayerId/PartOfName] [Interior]");
    }
    else return SendClientMessage(playerid, 0xD8D8D8FF, "You are not allowed to use this command.");
}
You can't check if the players connected at the initial start of the code when you never even input the value of ID. Use sscanf first then check if the players connected, so the ID is actually issued rather than being zero.


Re: Command help let's player do when other's not conencted - maramizo - 29.10.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
Sigh. You can't expect to ever be a good coder if you cannot think logically. When a variable is initialized, its value is 0. What do you think will happen when the code reaches that first check?
I lol'd so fucking hard at this.