I'm blind, help me @y_commands
#1

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;
}
Reply
#2

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

Thanks,

Jack_Rocker
Reply
#3

Can you post the warnings/errors you get in the compiler?
Reply
#4

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).
Reply
#5

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!
Reply
#6

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.
Reply
#7

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?
Reply
#8

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.
Reply
#9

Change

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

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


Forum Jump:


Users browsing this thread: 3 Guest(s)