1 error
#1

hello guys i am currently working on my AdminSystem and im doing a code which is when an rcon Admin chat ingame [RCON ADMIN] will be behind his/her name because i have no Admin levels yet :P but i am having a little problem with it, when compiling i get 1 error which is :

pawn Код:
C:\Users\xxx\Desktop\SAMP Servers\SAMP Gamemode\GM And FS\GM\NWS.pwn(690) : error 029: invalid expression, assumed zero
and here's the code

pawn Код:
public OnPlayerText(playerid, text[])
{
    IsPlayerAdmin(playerid);
    {
    new string[128];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(string, sizeof(string), "[RCON ADMIN] %s (%d): %s", name, playerid, text);
    SendPlayerMessageToAll(playerid, string);
    }
    else
    {
    new string2[128];
    new name2[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name2, sizeof (name2));
    format(string2, sizeof(string2), "%s (%d): %s", name2, playerid, text);
    SendPlayerMessageToAll(playerid, string2);
    }
    return 0;
}
the line that is causing the problem is

pawn Код:
{
else // this one
}
but its something is weird because my restart command to restart the server have this else and it works correctly

here's the code

pawn Код:
CMD:restart(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
    SendRconCommand("gmx");
    }
    else
    {
    SendClientMessage(playerid, 0xFF6347AA, "[RCON COMMAND] You Need to Be Loged in as RCON Admin, to use that command");
    }
    return 1;
}
Hope you can help me Thank you.
Reply
#2

Код:
if(IsPlayerAdmin(playerid))
{
...
}
else
{
...
}
Reply
#3

Quote:
Originally Posted by Andre02
Посмотреть сообщение
hello guys i am currently doing a code which is when an rcon Admin chat ingame [RCON ADMIN] will be behind his/her name but i am having a little problem with it, when compiling i get 1 error which is:

pawn Код:
C:\Users\xxx\Desktop\SAMP Servers\SAMP Gamemode\GM And FS\GM\NWS.pwn(690) : error 029: invalid expression, assumed zero
and here's the code

pawn Код:
public OnPlayerText(playerid, text[])
{
    IsPlayerAdmin(playerid);
    {
    new string[128];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof (name));
    format(string, sizeof(string), "[RCON ADMIN] %s (%d): %s", name, playerid, text);
    SendPlayerMessageToAll(playerid, string);
    }
    else
    {
    new string2[128];
    new name2[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name2, sizeof (name2));
    format(string2, sizeof(string2), "%s (%d): %s", name2, playerid, text);
    SendPlayerMessageToAll(playerid, string2);
    }
    return 0;
}
the line that is causing the problem is

pawn Код:
{
else // this one
}
but its something is weird because my restart command to restart the server have this else and it works correctly

here's the code

pawn Код:
CMD:restart(playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
    SendRconCommand("gmx");
    }
    else
    {
    SendClientMessage(playerid, 0xFF6347AA, "[RCON CMD] You Need to Be Loged in as RCON Admin, to use that command");
    }
    return 1;
}
Hope you can help me Thank you.
The problem is actually "IsPlayerAdmin(playerid);"
You have to use "if(IsPlayerAdmin(playerid))".

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128];
    new name[MAX_PLAYER_NAME];
    if(IsPlayerAdmin(playerid))
    {
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "[RCON ADMIN] %s (%d): %s", name, playerid, text);
    SendPlayerMessageToAll(playerid, string), string = "\0";
    }
    else
    {
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s (%d): %s", name, playerid, text);
    SendPlayerMessageToAll(playerid, string), string = "\0";
    }
    return 0;
}
E: Too late
Reply
#4

Yes it was that Thank you
+Rep'd
Reply
#5

now i have a 2nd problem i used your code but i cant talk Ingame :/ when i write something and send it it doesn't appear in the chat
Reply
#6

little bump :/
Reply
#7

Try
pawn Код:
public OnPlayerText(playerid, text[]) //This is called every time a player tries to type something, other than a command, such as when talking to other players
{
    if(IsPlayerAdmin(playerid)) //If they are an admin, you can replace this with your own admin variable
    {
        new string[150], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(string,sizeof(string),"[RCON ADMIN] %s: %d", name,playerid, text); //Editing the format and adding admin tag in front of name
        SendClientMessageToAll(0xFFFF00FF, string); //Sends message to all
        return 0; //Return false for sending custom chat, so it doesn't send your message twice
    }
    return 1; //Otherwise return 1 and send the message as normal
}
https://sampforum.blast.hk/showthread.php?tid=403293
Reply
#8

Quote:
Originally Posted by silenthill
Посмотреть сообщение
Try
pawn Код:
public OnPlayerText(playerid, text[]) //This is called every time a player tries to type something, other than a command, such as when talking to other players
{
    if(IsPlayerAdmin(playerid)) //If they are an admin, you can replace this with your own admin variable
    {
        new string[150], name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(string,sizeof(string),"[RCON ADMIN] %s: %d", name,playerid, text); //Editing the format and adding admin tag in front of name
        SendClientMessageToAll(0xFFFF00FF, string); //Sends message to all
        return 0; //Return false for sending custom chat, so it doesn't send your message twice
    }
    return 1; //Otherwise return 1 and send the message as normal
}
https://sampforum.blast.hk/showthread.php?tid=403293
sorry for the late reply i've been busy, this code makes my server crash! :/ everytime i open samp_server.exe it open but it close 1 second later.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)