SA-MP Forums Archive
Question - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Question (/showthread.php?tid=214587)



Question - Jimbo01 - 21.01.2011

Today i saw in my gamemode that i'm using string "32" but on most of the gamemodes its 64 ? should i change it to 64 ?

public OnPlayerRegister(playerid, password[])
{
if(IsPlayerConnected(playerid))
{
new string3[32];
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
format(string3, sizeof(string3), "accounts/%s.ini", playername3);
new File: hFile = fopen(string3, io_write);
if (hFile)
{
strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 255);
new var[32];
format(var, 32, "pKey=%s\n", PlayerInfo[playerid][pKey]);fwrite(hFile, var);
format(var, 32, "pCash=%d\n", PlayerInfo[playerid][pCash]);fwrite(hFile, var);


Re: Question - Kwarde - 21.01.2011

You can also change it to 15 xD
Quote:

accounts/%s.ini

That's 15 characters long. So 17 bits used for nothing


Re: Question - Joe Staff - 21.01.2011

Well unless someone's name is %s, I think you should account for MAX_PLAYER_NAME


It should actually be 37


Re: Question - MadeMan - 21.01.2011

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
You can also change it to 15 xD

That's 15 characters long. So 17 bits used for nothing
It's 13 characters plus 20 characters for player's name (13+20=33). So you could change to 64.


Re: Question - Joe Staff - 21.01.2011

Quote:
Originally Posted by a_samp.inc
// Limits and internal constants
#define MAX_PLAYER_NAME (24)
MAX_PLAYER_NAME is actually 24, not 20


Re: Question - Sascha - 21.01.2011

well... change it to 50 and you'll be fine lol....


Re: Question - Kwarde - 21.01.2011

https://sampforum.blast.hk/showthread.php?tid=55261

Quote:
Originally Posted by ******, the god scripter
By my count there are 47 characters in that string, 2 of which are the "%d" which won't appear in the final string, so 45 to go in the final string. We've already ascertained that the longest the number will be is 4 (if you want to be on the REALLY safe side, the longest a PAWN integer can possibly ever be is 11 characters (-2147483647)), and we know that all strings require a NULL at the end, so the longest this string can ever possibly get to is:

47 - 2 + 4 + 1 = 50

50 cells, so why use 256, it's just a waste of 206 cells (824 bytes - that's nearly a kilobyte of wasted memory)?
No not 64! Just 37!!! - And I didn't read it good. Indeed not 15 :P. But then use 37!!!!


Re: Question - MadeMan - 21.01.2011

Quote:
Originally Posted by SilentHuntR
Посмотреть сообщение
MAX_PLAYER_NAME is actually 24, not 20
https://sampwiki.blast.hk/wiki/Limits

Quote:

Name Length 20 characters.

But according to this page, player's name can be only 20 chars long.


Re: Question - Kwarde - 21.01.2011

Quote:
Originally Posted by #include <a_samp>
#define MAX_PLAYER_NAME (24)
a_samp says 24 :')


Re: Question - Joe Staff - 21.01.2011

You can only connect to a server with 20 characters in your name, but the server could change your name to be 24 characters