SA-MP Forums Archive
Why do I get these errors? - 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: Why do I get these errors? (/showthread.php?tid=282271)



Why do I get these errors? - Tigerbeast11 - 10.09.2011

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '*' && PlayerInfo[playerid][ALevel] >= 1)
    {
        new name;
        new string;
        GetPlayerName(playerid,name,24); //190
        format(string,sizeof(string),"Admin Chat: %s (id:%d): %s",name,playerid,text[1]); //191
        SendMessageToAdmins(string);
        return 0;
    }
    return 1;
}

stock SendMessageToAdmins(text[])
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][ALevel] >= 1 && IsPlayerConnected(i))
        {
            SendClientMessage(i,blue,text);
            return 1;
        }
    }
}
Why am I getting these errors?

Код:
test.pwn(190) : error 035: argument type mismatch (argument 2)
test.pwn(191) : error 035: argument type mismatch (argument 1)
test.pwn(191) : error 035: argument type mismatch (argument 1)
test.pwn(192) : error 035: argument type mismatch (argument 1)
test.pwn(189) : warning 203: symbol is never used: "string"
test.pwn(208) : warning 209: function "SendMessageToAdmins" should return a value



Re: Why do I get these errors? - =WoR=G4M3Ov3r - 10.09.2011

Its because you're using them the wrong way, tell me which lines are 190, 191, and 192

I'll tell you the proper way to use em.


Re: Why do I get these errors? - FireCat - 10.09.2011

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '*' && PlayerInfo[playerid][ALevel] >= 1)
    {
        new name[MAX_PLAYER_NAME];
        new string;
        GetPlayerName(playerid,name,24); //190
        format(string,sizeof(string),"Admin Chat: %s (id:%d): %s",name,playerid,text[1]); //191
        SendMessageToAdmins(string);
        return 0;
    }
    return 1;
}

stock SendMessageToAdmins(text[])
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][ALevel] >= 1 && IsPlayerConnected(i))
        {
            SendClientMessage(i,blue,text);
            return 1;
        }
    }
}



Re: Why do I get these errors? - Tigerbeast11 - 10.09.2011

Quote:
Originally Posted by FireCat
Посмотреть сообщение
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '*' && PlayerInfo[playerid][ALevel] >= 1)
    {
        new name[MAX_PLAYER_NAME];
        new string;
        GetPlayerName(playerid,name,24); //190
        format(string,sizeof(string),"Admin Chat: %s (id:%d): %s",name,playerid,text[1]); //191
        SendMessageToAdmins(string);
        return 0;
    }
    return 1;
}

stock SendMessageToAdmins(text[])
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][ALevel] >= 1 && IsPlayerConnected(i))
        {
            SendClientMessage(i,blue,text);
            return 1;
        }
    }
}
Hmm... Still the same :/

I get the errors on the format string line now.


Re: Why do I get these errors? - FireCat - 10.09.2011

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '*' && PlayerInfo[playerid][ALevel] >= 1)
    {
        new name[MAX_PLAYER_NAME];
        new string[64];
        GetPlayerName(playerid,name,sizeof(name)); //190
        format(string,sizeof(string),"Admin Chat: %s (id:%d): %s",name,playerid,text[1]); //191
        SendMessageToAdmins(string);
        return 0;
    }
    return 1;
}

stock SendMessageToAdmins(text[])
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(PlayerInfo[i][ALevel] >= 1 && IsPlayerConnected(i))
        {
            SendClientMessage(i,blue,text);
            return 1;
        }
    }
}



Re: Why do I get these errors? - =WoR=G4M3Ov3r - 10.09.2011

@FireCat.

PHP код:
GetPlayerName(playeridnamesizeof(name)); 
You replaces sizeof with with a number.

PHP код:
format(stringsizeof(string), "Admin Chat: %s (id:%d): %s" name ,playerid ,text[1]) 
You're using 6 parameters, when it should be 5.


Re: Why do I get these errors? - Tigerbeast11 - 10.09.2011

It still says "SendMessageToAdmins" should return a value.

EDIT: Fixed!


Re: Why do I get these errors? - IceCube! - 10.09.2011

Removed: Fixed ^^


Re: Why do I get these errors? - Kush - 10.09.2011

Quote:
Originally Posted by Tigerbeast11
Посмотреть сообщение
It still says "SendMessageToAdmins" should return a value.

EDIT: Fixed!
PHP код:
forward SendMessageToAdmins(string[]);
public 
SendMessageToAdmins(string[]) {
foreach(
Playeri) {
if(
PlayerInfo[i][ALevel] >= || IsPlayerAdmin(i)) {
    
SendClientMessage(ibluestring);
        }
    }

or

PHP код:
stock SendMessageToAdmins(text[])
{
    for(new 
iMAX_PLAYERSi++)
    {
        if(
PlayerInfo[i][ALevel] >= && IsPlayerConnected(i))
        {
            
SendClientMessage(i,blue,text);
        }
    }
    return 
1//return the value of the compound function before it is enclosed.




Re: Why do I get these errors? - Sasino97 - 10.09.2011

An error is that "string" has only 1 cell (It's not an array), it MUST be an array for containing a string.


Re: Why do I get these errors? - =WoR=G4M3Ov3r - 10.09.2011

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
An error is that "string" has only 1 cell (It's not an array), it MUST be an array for containing a string.
I believe he fixed it.


Re: Why do I get these errors? - Sasino97 - 10.09.2011

Quote:
Originally Posted by G4M3Ov3r
Посмотреть сообщение
I believe he fixed it.
I didn't read FireCat's code