How to load IP & An string MYSQL PROBLEM -
Metharon - 23.08.2014
Look.
In "LoadPlayer" function i have for int..
Код:
PlayerInfo[ playerid ][ pPosZ ] = cache_get_field_content_float( 0, "sPosZ", SQL );
But how can i load an string and ip from database?
i tried , but it's not working..
Код:
PlayerInfo[ playerid ][ Tag ] = cache_get_field_content_int( 0, "TAG", SQL );
PlayerInfo[ playerid ][ IP ] = cache_get_field_content_int( 0, "IP", SQL );
+ Also can somebody explain me how to put an ip into a textdraw? ... i tried
Код:
format(string, sizeof(string),"IP: ~R~%s", PlayerInfo[playerid][IP]);
but is not working... ? i mean isn't loading the ip , the textdraw is only IP : *nothing there*
+ How can i save the IP FROM PLAYER?

instead of 127.0.0.1 in database is saved 2552555?!
i save them in this way..
Код:
new plrIP[128];
GetPlayerIp(playerid, plrIP, sizeof(plrIP));
format( query7, sizeof( query7 ), "UPDATE `users` SET `IP` = '%s', `tApartament` = %d, `tMasina` = %d, `TAG` = '%s' WHERE `Name` = '%s'", plrIP, PlayerInfo[playerid][tApartament], PlayerInfo[playerid][tMasina], PlayerInfo[playerid][Tag], name);
+1 for the one who help me , with these problems... is the frist time i try to save & load an string.. + an ip..
Re: How to load IP & An string MYSQL PROBLEM -
RoW001 - 23.08.2014
cache_get_field_content( 0, "IP", PlayerInfo[playerid][IP], yourHandle, Variablesize );
Re: How to load IP & An string MYSQL PROBLEM -
Djole1337 - 23.08.2014
GetPlayerIp always returns 255.255.255.255 under OnPlayerDisconnect. Save it under OnPlayerConnect.
Re: How to load IP & An string MYSQL PROBLEM -
Metharon - 23.08.2014
ok but what format i need to save ? i mean the ip need to be %s or %p ?
+ about the string.. ? how i load the TAG and save?
Re: How to load IP & An string MYSQL PROBLEM -
Sawalha - 23.08.2014
1.
For loading a string
pawn Код:
cache_get_field_content(0, "TAG", pInfo[playerid][Tag], SQL, (length of tag) // if you are using r39 version);
You see that IP includes the charcater '.' (129.212.1 etc.. )
So it's a string, not an integer , Load it same as up ^
2. You use textdrawsetstring right? if yes, you forgot something:
pawn Код:
GetPlayerIp(playerid, pInfo[playerid][IP], 16);
format(string, sizeof(string),"IP: ~R~%s", PlayerInfo[playerid][IP]);
Then use TextDrawSetString to set the string as player's IP.
You have to put [16] next to your "IP" in the pInfo array Like:
pawn Код:
enum DATA
{
IP[16],
etc etc..
}
Right? just put the [16] to define it's size so it will not give you an error.
3.
You don't have to use 128 cells for an IP, IP's max cells is 16.
So it will be
EDIT:
as he said ^
Quote:
Originally Posted by Djole1337
GetPlayerIp always returns 255.255.255.255 under OnPlayerDisconnect. Save it under OnPlayerConnect.
|
Re: How to load IP & An string MYSQL PROBLEM -
Metharon - 23.08.2014
Ok , is 50 % fixed... but.
1. At login , i want to get the IP from DB and to put into the textdraw, not to get the ip of the player who connected with the name ...
2. The tag have a SPACE? between them ? why ? look.
Код:
format(string, sizeof(string), "{FFF1AF}- {FF9966}(#%s){FFF1AF} %s » %s" ,PlayerInfo[playerid][Tag],RemoveUnderScore(playerid), text);
look how i load it
Код:
PlayerInfo[ playerid ][ IP ] = cache_get_field_content( 0, "IP", PlayerInfo[playerid][IP], SQL, 128 );
PlayerInfo[ playerid] [ Tag ] = cache_get_field_content(0, "TAG", PlayerInfo[playerid][Tag], SQL, 5);
my playerinfo..
Код:
enum pInfo
{
Password[ 129 ],
pName[ 24 ],
Administrator,
Job,
Money,
MoneyInBank,
Sex,
Blocare,
Float:pPosX,
Float:pPosY,
Float:pPosZ,
Float:pAngle,
pSkin,
Varsta,
OreJucate,
FactionID,
FactionRank,
Nivel,
Respect,
RespectNEC,
Salariul,
NumarMobil,
Advertismente,
pStagiuTut,
pLicentaCondus,
pIncCondus,
pSpawnChoose,
pMute,
pMuteTime,
aFlag,
Helper,
hFlag,
Float:DinamicX,
Float:DinamicY,
Float:DinamicZ,
Float:DinamicA,
Donator,
pATMcard,
CarLic,
FlyLic,
GunLic,
BoatLic,
PhoneCard,
Cars[ 50 ],
pHomes[ 50 ],
OffMessage[ 128 ],
Banned,
PayDays,
xRenter,
xHouseRentID,
RobState,
Tag[5], <----
tApartament,
tMasina,
IP[128] <----
}
+ Can you look at my db settings for fields?
Re: How to load IP & An string MYSQL PROBLEM -
Virtual1ty - 23.08.2014
Okay, how do you first save that "IP"? I don't see why would that field need to be of 132 width, as well.
As to why the tag has a space, try to use another character instead of the "hashtag".
Re: How to load IP & An string MYSQL PROBLEM -
RoW001 - 23.08.2014
Tag[5] is 5 and you sql configuration have 24.
Get tag with this.
cache_get_field_content( 0, "TAG", PlayerInfo[ playerid ][ Tag ], SQL( YOur COnection Handle ), 5 );
Re: How to load IP & An string MYSQL PROBLEM -
Metharon - 23.08.2014
Can somebody please teach how to save the ip into the db... ? i mean what configuration for field info ... and in gamemode?
Re: How to load IP & An string MYSQL PROBLEM -
RoW001 - 23.08.2014
//At OnPlayerLogin
new Playa_IP[ 16 ], szQuery[ 128 ];
GetPlayerIP( playerid, Playa_IP, 16 );
format( PlayerInfo[ playerid ][ IP ], 16, Playa_IP );
format( szQuery, 128, "UPDATE `users` SET `IP` = '%s' WHERE `Name` = '%s' LIMIT 1;", Playa_IP, GetName( playerid ) );
mysql_tquery( SQL(Your Connection Handle), szQuery, "", "" );
AT OnPlayerLoadData( Your callback for load data )
cache_get_field_content( 0, "IP", PlayerInfo[ playerid ][ IP ], SQL( Your Conn Handle ), 16 );
And change IP configuration in Database to varchar( 16 )