15.04.2017, 20:50
Hello!
Is better to do, this:
So I can use the IP and SERIAL variables later at any time using
or this way:
I think the second way uses more memory because it creaste a string of 42 bytes (serial) everytime, but I'm not sure.
Meaning of ram memory/cpu/etc.. which is better to use and why?
Thank you.
Is better to do, this:
PHP код:
enum ePlayerData{
accountid,
score,
money,
IP[17],
SERIAL[42],
deaths
}
new PlayerData[MAX_PLAYERS][ePlayerData];
stock StorePlayerSerial(iPlayerID)
{
new
szSerial[41]; // 40 + \0
gpci(iPlayerID, szSerial, sizeof(szSerial));
memcpy(PlayerData[iPlayerID][SERIAL], szSerial, 0, strlen(szSerial) * 4, 42);
return szSerial;
}
//here it's not possible to return PlayerInfo[playerid][IP] because it will return a wrong value, I know. However I can use the PlayerInfo[playerid][IP] variable in the whole gamemode without problems, I have tested it.
stock StorePlayerIP(playerid)
{
GetPlayerIp(playerid, PlayerInfo[playerid][IP], 17);
return 1;
}
PHP код:
PlayerData[playerid][IP]
PHP код:
stock GetPlayerIP(playerid)
{
new ipaddr[17];
GetPlayerIp(playerid, ipaddr, sizeof(ipaddr));
return ipaddr;
}
stock GetPlayerSerial(iPlayerID)
{
new szSerial[42];
gpci(iPlayerID, szSerial, sizeof(szSerial));
return szSerial;
}
Meaning of ram memory/cpu/etc.. which is better to use and why?
Thank you.