SetPlayerInfo give some erros
#1

Hi!

I have another question.


My function give some errors

Код:
stock SetPlayerInfo(playerid, info[], newinfo[])
{
      AccountInfo[playerid][info]=newinfo;
      return 1;
}
Код:
\pawno\include\gamemode/account.inc(175) : error 033: array must be indexed (variable "info")
\pawno\include\gamemode/account.inc(175) : error 006: must be assigned to an array
This is how I use this function (example):
SetPlayerInfo(playerid, "WarnReason", "DM To Much"); //SetPlayerInfo(playerid, info[], newinfo[])
Reply
#2

pawn Код:
stock SetPlayerInfo(playerid, info[], newinfo[])
{
      AccountInfo[playerid][info] = newinfo;
      return 1;
}
Reply
#3

The [] signs are used for strings only!
pawn Код:
stock SetPlayerInfo(playerid, info, newinfo)
{
      AccountInfo[playerid][info]=newinfo;
      return 1;
}
Quote:
Originally Posted by Schurman
Посмотреть сообщение
pawn Код:
stock SetPlayerInfo(playerid, info[], newinfo[])
{
      AccountInfo[playerid][info] = newinfo;
      return 1;
}
The code is exactly the same! PAWN is not sensitive to whitespace additions.
pawn Код:
x=x+1;
// is the same of
x = x + 1;
// and viceversa
Reply
#4

Yes, thats what I want.

This is how I use this function (example):

SetPlayerInfo(playerid, "WarnReason", "DM To Much"); //SetPlayerInfo(playerid, info[], newinfo[])
Reply
#5

what about:
pawn Код:
stock SetPlayerInfo(playerid, info[], newinfo[])
{
      format(AccountInfo[playerid][info], sizeof(AccountInfo[playerid][info]), "%s", newinfo);
      return 1;
}
not sure whether this will work though
Reply
#6

Your WarnReason can't be a string, it must be
pawn Код:
SetPlayerInfo(playerid, WarnReason, "DM To Much"); //SetPlayerInfo(playerid, info[], newinfo[])
So, you'd have to make a special function for strings, and for integers, etc.
Reply
#7

How do you mean?

Can you give an example?
Reply
#8

What name did you give your enumerator? You'll need that as a tag for your function.
pawn Код:
SetPlayerInfo(playerid, pInfo:info, int_newinfo, str_newinfo[] = "")
{
    if(strlen(str_newinfo))
    {
        // There's some string passed, copy it
        strcat((AccountInfo[playerid][info] = EOS, AccountInfo[playerid][info]), str_newinfo);
        return 1;
    }
    AccountInfo[playerid][info] = int_newinfo;
    return 1;
}
Reply
#9

Nice and thanks!,

I see where the info will be set if it is an int, but where does it set the info if it is a string?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)