Writing string into variable(enum)
#7

Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
Really offtopic: Bosanac si, ime varijable ("porijeklo") ti je na hrvatskom, a tekst registracije na srpskom ("kako biste se registrovali.. ") - tko tu koga.. !?
On topic:
Use strcpy to insert a string to a variable, search for that function in Code optimisations topic, example:
pawn Код:
strcpy(pInfo[playerid][pPorijeklo], "Hrvatska", 32);
Quote:
Originally Posted by CutX
Посмотреть сообщение
the best way to accomplish something like this is using memcpy
(faster than using format)

pawn Код:
memcpy(pInfo[playerid][pPorijeklo], "Hrvatska", 0, 32);
It doesn't work: http://prntscr.com/4dbvxn as you see Porijeklo is empty.

@Virtual1ty - When i use strcpy i got these errors.
Код:
RP.pwn(58) : warning 201: redefinition of constant/macro (symbol "strcpy(%0,%1,%2)")
RP.pwn(467) : error 001: expected token: ")", but found "["
RP.pwn(467) : warning 215: expression has no effect
RP.pwn(467) : error 001: expected token: ";", but found "]"
RP.pwn(467) : error 029: invalid expression, assumed zero
RP.pwn(467) : fatal error 107: too many error messages on one line
@Sarra - When i use format only one letter write: http://prntscr.com/4dbwv1 , and i can't use pInfo[playerid][pPorijeklo] = "Hrvatska"; (must be assigned to an array)


Код:
enum PlayerInfo
{
    pLozinka[129], 
    pAdmin, 
    pHelper, 
    pDonator, 
    pLevel, 
    pUbojstva, 
    pNovac,
    pSmrti,
    pGodine,
    pSpol,
    pPorijeklo,
    pEmail,
    pRegistrovan,
    pTutorial 
}
new pInfo[MAX_PLAYERS][PlayerInfo];
Код:
public OnPlayerDisconnect(playerid, reason)
{
        new INI:file = INI_Open(Path(playerid)); 
        INI_SetTag(file,"Podatci");
        INI_WriteInt(file,"Admin",pInfo[playerid][pAdmin]); 
        INI_WriteInt(file,"Helper",pInfo[playerid][pHelper]);
        INI_WriteInt(file,"Donator",pInfo[playerid][pDonator]);
        INI_WriteInt(file,"Novac",GetPlayerMoney(playerid));
        INI_WriteInt(file,"Level",GetPlayerScore(playerid));
        INI_WriteInt(file,"Ubojstva",pInfo[playerid][pUbojstva]);
        INI_WriteInt(file,"Smrti",pInfo[playerid][pSmrti]);
        INI_WriteInt(file,"Godine",pInfo[playerid][pGodine]);
        INI_WriteInt(file,"Spol",pInfo[playerid][pSpol]);
        INI_WriteString(file,"Porijeklo",pInfo[playerid][pPorijeklo]);
        INI_WriteString(file,"Email",pInfo[playerid][pEmail]);
        INI_Close(file);
        return 1;
}
Код:
forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
    INI_String("Lozinka", pInfo[playerid][pLozinka],129); 
    INI_Int("Admin",pInfo[playerid][pAdmin]);
    INI_Int("Helper",pInfo[playerid][pHelper]);
    INI_Int("Donator",pInfo[playerid][pDonator]);
    INI_Int("Novac",pInfo[playerid][pNovac]); 
    INI_Int("Level",pInfo[playerid][pLevel]);
    INI_Int("Ubojstva",pInfo[playerid][pUbojstva]);
    INI_Int("Smrti",pInfo[playerid][pSmrti]);
    INI_Int("Godine",pInfo[playerid][pGodine]);
    INI_Int("Spol",pInfo[playerid][pSpol]);
    INI_Int("Porijeklo",pInfo[playerid][pPorijeklo]);
    INI_Int("Email",pInfo[playerid][pEmail]);
    return 1;
}
If you got confused about writing string loading like int, i don't know i was searching and find this solution.
Reply


Messages In This Thread
Writing string into variable(enum) - by hrasch - 15.08.2014, 20:38
Re: Writing string into variable(enum) - by Virtual1ty - 15.08.2014, 21:38
Re: Writing string into variable(enum) - by hrasch - 16.08.2014, 09:08
Re: Writing string into variable(enum) - by CutX - 16.08.2014, 09:14
Re: Writing string into variable(enum) - by Virtual1ty - 16.08.2014, 09:20
Re: Writing string into variable(enum) - by Sarra - 16.08.2014, 09:25
Re: Writing string into variable(enum) - by hrasch - 16.08.2014, 09:54
Re: Writing string into variable(enum) - by Sarra - 16.08.2014, 10:10
Re: Writing string into variable(enum) - by hrasch - 16.08.2014, 10:17
Re: Writing string into variable(enum) - by hrasch - 16.08.2014, 10:25

Forum Jump:


Users browsing this thread: 1 Guest(s)