SA-MP Forums Archive
I'm blind, help me @y_commands - 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: I'm blind, help me @y_commands (/showthread.php?tid=338469)



I'm blind, help me @y_commands - notepad - 29.04.2012

I'm sleepy as hell and I need to finish a few things before I go to bed, so please tell me what the hell is wrong because I can't see.

pawn Код:
YCMD:invite(playerid, params[], help)
{
    #pragma unused help

    if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pCop] != 2)
    {
        SendClientMessage(playerid, -1, "You are not an Admin or a Cop chief.");
    }
    else if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pCop] == 2)
    {
        new PlayerID, PlayerName[MAX_PLAYER_NAME], TargetName[MAX_PLAYER_NAME], string[128];

        if(sscanf(params, "u", PlayerID)) return SendClientMessage(playerid, -1, "Usage mode: /invite [PlayerName / ID]");

        if(PlayerID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "[ERROR] Invalid ID.");

        PlayerInfo[PlayerID][pCop] = 1;

        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        GetPlayerName(PlayerID, TargetName, sizeof(TargetName));

        format(string, sizeof(string), "You have been promoted to cop by %s.", PlayerName);
        SendClientMessage(PlayerID, -1, string);

        format(string, sizeof(string), "You have invited %s to cop.", TargetName);
        SendClientMessage(playerid, -1, string);
    }
    return 1;
}



Re: I'm blind, help me @y_commands - Jack_Rocker - 29.04.2012

Please could you tell us the error (or problem) you are receiving?

Thanks,

Jack_Rocker


Re: I'm blind, help me @y_commands - stormchaser206 - 29.04.2012

Can you post the warnings/errors you get in the compiler?


Re: I'm blind, help me @y_commands - notepad - 29.04.2012

Quote:
Originally Posted by Jack_Rocker
Посмотреть сообщение
Please could you tell us the error (or problem) you are receiving?

Thanks,

Jack_Rocker
Oh, I forgot about that.

There are no errors/warnings when compiling, but when I use the command ingame it always executes this

pawn Код:
SendClientMessage(playerid, -1, "You are not an Admin or a Cop chief.");
no matter if I'm logged in or not (rcon).


Re: I'm blind, help me @y_commands - Jack_Rocker - 29.04.2012

pawn Код:
YCMD:invite(playerid, params[], help)
{
    #pragma unused help
    if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pCop] != 2)
    {
        SendClientMessage(playerid, -1, "You are not an Admin or a Cop chief.");
    }
    else //'else if' should only be used if there are more than two things going on... 'else' by itself is enough :)
    {
        new PlayerID, PlayerName[MAX_PLAYER_NAME], TargetName[MAX_PLAYER_NAME], string[128];

        if(sscanf(params, "u", PlayerID)) return SendClientMessage(playerid, -1, "Usage mode: /invite [PlayerName / ID]");

        if(PlayerID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "[ERROR] Invalid ID.");

        PlayerInfo[PlayerID][pCop] = 1;

        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        GetPlayerName(PlayerID, TargetName, sizeof(TargetName));

        format(string, sizeof(string), "You have been promoted to cop by %s.", PlayerName);
        SendClientMessage(PlayerID, -1, string);

        format(string, sizeof(string), "You have invited %s to cop.", TargetName);
        SendClientMessage(playerid, -1, string);
    }
    return 1;
}
Try that!


Re: I'm blind, help me @y_commands - notepad - 29.04.2012

Quote:
Originally Posted by Jack_Rocker
Посмотреть сообщение
pawn Код:
YCMD:invite(playerid, params[], help)
{
    #pragma unused help
    if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pCop] != 2)
    {
        SendClientMessage(playerid, -1, "You are not an Admin or a Cop chief.");
    }
    else //'else if' should only be used if there are more than two things going on... 'else' by itself is enough :)
    {
        new PlayerID, PlayerName[MAX_PLAYER_NAME], TargetName[MAX_PLAYER_NAME], string[128];

        if(sscanf(params, "u", PlayerID)) return SendClientMessage(playerid, -1, "Usage mode: /invite [PlayerName / ID]");

        if(PlayerID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "[ERROR] Invalid ID.");

        PlayerInfo[PlayerID][pCop] = 1;

        GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
        GetPlayerName(PlayerID, TargetName, sizeof(TargetName));

        format(string, sizeof(string), "You have been promoted to cop by %s.", PlayerName);
        SendClientMessage(PlayerID, -1, string);

        format(string, sizeof(string), "You have invited %s to cop.", TargetName);
        SendClientMessage(playerid, -1, string);
    }
    return 1;
}
Try that!
I added that secound "if" just to test hehe

It doesn't work.

But thanks anyways for reminding me.


Re: I'm blind, help me @y_commands - Jack_Rocker - 29.04.2012

pawn Код:
YCMD:invite(playerid, params[], help)
{
    new PlayerID, PlayerName[MAX_PLAYER_NAME], TargetName[MAX_PLAYER_NAME], string[128];
    #pragma unused help
    if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pCop] != 2) return SendClientMessage(playerid, -1, "You are not an Admin or a Cop chief.");
   
    if(sscanf(params, "u", PlayerID)) return SendClientMessage(playerid, -1, "Usage mode: /invite [PlayerName / ID]");

    if(PlayerID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "[ERROR] Invalid ID.");

    PlayerInfo[PlayerID][pCop] = 1;

    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    GetPlayerName(PlayerID, TargetName, sizeof(TargetName));

    format(string, sizeof(string), "You have been promoted to cop by %s.", PlayerName);
    SendClientMessage(PlayerID, -1, string);

    format(string, sizeof(string), "You have invited %s to cop.", TargetName);
    SendClientMessage(playerid, -1, string);

    return 1;
}
Maybe this?


Re: I'm blind, help me @y_commands - notepad - 29.04.2012

Quote:
Originally Posted by Jack_Rocker
Посмотреть сообщение
pawn Код:
YCMD:invite(playerid, params[], help)
{
    new PlayerID, PlayerName[MAX_PLAYER_NAME], TargetName[MAX_PLAYER_NAME], string[128];
    #pragma unused help
    if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pCop] != 2) return SendClientMessage(playerid, -1, "You are not an Admin or a Cop chief.");
   
    if(sscanf(params, "u", PlayerID)) return SendClientMessage(playerid, -1, "Usage mode: /invite [PlayerName / ID]");

    if(PlayerID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "[ERROR] Invalid ID.");

    PlayerInfo[PlayerID][pCop] = 1;

    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
    GetPlayerName(PlayerID, TargetName, sizeof(TargetName));

    format(string, sizeof(string), "You have been promoted to cop by %s.", PlayerName);
    SendClientMessage(PlayerID, -1, string);

    format(string, sizeof(string), "You have invited %s to cop.", TargetName);
    SendClientMessage(playerid, -1, string);

    return 1;
}
Maybe this?
Nop.


Re: I'm blind, help me @y_commands - SuperViper - 30.04.2012

Change

pawn Код:
if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pCop] != 2)
to

pawn Код:
if(!IsPlayerAdmin(playerid) && PlayerInfo[playerid][pCop] != 2)