SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 15/02/2012, 04:12 PM   #1
doreto
High-roller
 
doreto's Avatar
 
Join Date: Aug 2010
Posts: 1,667
Reputation: 118
Default Mysql GetPlayerIP something wrong

i wonna to store ip on player when he disconnect and here my code
PHP Code:
public OnPlayerDisconnect(playeridreason)
{
    new 
Query[100];
    
format(Query,sizeof(Query),"UPDATE playerdata SET money=%d, score=%d, ip=%s  WHERE username='%s'",GetPlayerMoney(playerid),GetPlayerScore(playerid),GetPlayerIP(playerid),PlayerName(playerid));
    
mysql_query(Query);

    return 
true;

and my stock for GetPlayerIP
PHP Code:
stock GetPlayerIP(playerid)
{
    new 
Ip[25];
    
GetPlayerIp(playeridIpsizeof(Ip));
    return 
Ip;

on mysql i use IP int(16) and sometimes store ip like 55 sometimes dont store (im 100% connect to datebase )
__________________
Quote:
Originally Posted by Kalcor View Post
This my site, so I get to decide what links are allowed. utube and 1e100 are no longer part of my web of trust.

The internet is more important to me than sa-mp. You don't get sa-mp without the internet.
Quote:
Originally Posted by [Twixx] View Post
That's kind of hypocritical of you to say. Sure you own the website, but it's not your personal blog or something - it's a community driven forum. The community should be the primary focus, not your personal agendas. Just like you don't get SA-MP without internet, you don't get SA-MP forums without community.

Just wiping out years worth of people's work and creations posted on that board because a bunch of people bypassed your Tube ban is absurd.
Quote:
Originally Posted by Mauzen View Post
"tube sucks cause they delete 6 years old videos for no reason!"

*deletes every single video ever posted here in 12 years*
doreto is offline   Reply With Quote
Old 15/02/2012, 04:23 PM   #2
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,089
Reputation: 2655
Default Re: Mysql GetPlayerIP something wrong

GetPlayerIp doesn't work properly in OnPlayerDisconnect, as the player is already disconnected at that point. It will return 255.255.255.255 (an invalid IP address) most of the time. You should update the IP when a player connects or logs in. The IP doesn't change while the player is connected, or does it?
__________________
Vince is offline   Reply With Quote
Old 15/02/2012, 04:27 PM   #3
KingHual
Banned
 
Join Date: Jun 2010
Location: Bulgaria
Posts: 2,297
Reputation: 1389
Default Re: Mysql GetPlayerIP something wrong

Solution: Do the same when a player logs in instead of doing it on player disconnect. Vince already explained why.
KingHual is offline   Reply With Quote
Old 15/02/2012, 04:30 PM   #4
doreto
High-roller
 
doreto's Avatar
 
Join Date: Aug 2010
Posts: 1,667
Reputation: 118
Default Re: Mysql GetPlayerIP something wrong

really ? hmm then how to record player ip when he connect

PHP Code:
        this is my login dialog


        format
(Query,sizeof(Query),"SELECT username FROM playerdata WHERE username='%s' AND password='%s'",PlayerName(playerid),inputtext);
        
mysql_query(Query);
        
mysql_store_result(); 
now i try to INSERT IP into db but nothing show
PHP Code:
format(Querysizeof(Query), "INSERT INTO playerdata IP VALUES '%s'",GetPlayerIP(playerid)); 
//GetPlayerIP i user my stock above
__________________
Quote:
Originally Posted by Kalcor View Post
This my site, so I get to decide what links are allowed. utube and 1e100 are no longer part of my web of trust.

The internet is more important to me than sa-mp. You don't get sa-mp without the internet.
Quote:
Originally Posted by [Twixx] View Post
That's kind of hypocritical of you to say. Sure you own the website, but it's not your personal blog or something - it's a community driven forum. The community should be the primary focus, not your personal agendas. Just like you don't get SA-MP without internet, you don't get SA-MP forums without community.

Just wiping out years worth of people's work and creations posted on that board because a bunch of people bypassed your Tube ban is absurd.
Quote:
Originally Posted by Mauzen View Post
"tube sucks cause they delete 6 years old videos for no reason!"

*deletes every single video ever posted here in 12 years*
doreto is offline   Reply With Quote
Old 15/02/2012, 04:39 PM   #5
iTorran
Gangsta
 
Join Date: Aug 2010
Posts: 543
Reputation: 88
Default Re: Mysql GetPlayerIP something wrong

pawn Code:
// Top of script
new PlayerIP[MAX_PLAYERS][16];

// Login
format(PlayerIP[playerid], 16, "%s", GetPlayerIP(playerid));

// Disconnect
Use "PlayerIP[playerid]"
iTorran is offline   Reply With Quote
Old 15/02/2012, 04:50 PM   #6
doreto
High-roller
 
doreto's Avatar
 
Join Date: Aug 2010
Posts: 1,667
Reputation: 118
Lightbulb Re: Mysql GetPlayerIP something wrong

Quote:
Originally Posted by iTorran View Post
pawn Code:
// Top of script
new PlayerIP[MAX_PLAYERS][16];

// Login
format(PlayerIP[playerid], 16, "%s", GetPlayerIP(playerid));

// Disconnect
Use "PlayerIP[playerid]"
its strange becose when i post your code
PHP Code:
    if( dialogid == DIALOG_LOGIN )
    {
        new 
Query[100];
        if(!
response) return
        
Kick(playerid),
        
SendClientMessage(playerid,-1,"Login exit");


        
format(Query,sizeof(Query),"SELECT username FROM playerdata WHERE username='%s' AND password='%s'",PlayerName(playerid),inputtext);
        new 
PlayerIP[MAX_PLAYERS][16];
        
format(PlayerIP[playerid], 16"%s"GetPlayerIP(playerid));
        
mysql_query(Query);
        
mysql_store_result(); 
its show me gamemode.pwn(353) : error 021: symbol already defined: "Query" << my register dialog
PHP Code:
    if( dialogid == DIALOG_REGISTER )
    {

        new 
Query[100];// line 353
        
if(!response) return
        
Kick(playerid),
        
SendClientMessage(playerid,COLOR_RED,"You have cansel to register!");

        
format(Query,sizeof(Query),"INSERT INTO playerdata (username,password,score,money,ip) VALUES ('%s','%s',0,0,'%s')",PlayerName(playerid),inputtext);
        
mysql_query(Query); 
__________________
Quote:
Originally Posted by Kalcor View Post
This my site, so I get to decide what links are allowed. utube and 1e100 are no longer part of my web of trust.

The internet is more important to me than sa-mp. You don't get sa-mp without the internet.
Quote:
Originally Posted by [Twixx] View Post
That's kind of hypocritical of you to say. Sure you own the website, but it's not your personal blog or something - it's a community driven forum. The community should be the primary focus, not your personal agendas. Just like you don't get SA-MP without internet, you don't get SA-MP forums without community.

Just wiping out years worth of people's work and creations posted on that board because a bunch of people bypassed your Tube ban is absurd.
Quote:
Originally Posted by Mauzen View Post
"tube sucks cause they delete 6 years old videos for no reason!"

*deletes every single video ever posted here in 12 years*
doreto is offline   Reply With Quote
Old 15/02/2012, 05:26 PM   #7
doreto
High-roller
 
doreto's Avatar
 
Join Date: Aug 2010
Posts: 1,667
Reputation: 118
Default Re: Mysql GetPlayerIP something wrong

anyone have idea ? sorry for dump
__________________
Quote:
Originally Posted by Kalcor View Post
This my site, so I get to decide what links are allowed. utube and 1e100 are no longer part of my web of trust.

The internet is more important to me than sa-mp. You don't get sa-mp without the internet.
Quote:
Originally Posted by [Twixx] View Post
That's kind of hypocritical of you to say. Sure you own the website, but it's not your personal blog or something - it's a community driven forum. The community should be the primary focus, not your personal agendas. Just like you don't get SA-MP without internet, you don't get SA-MP forums without community.

Just wiping out years worth of people's work and creations posted on that board because a bunch of people bypassed your Tube ban is absurd.
Quote:
Originally Posted by Mauzen View Post
"tube sucks cause they delete 6 years old videos for no reason!"

*deletes every single video ever posted here in 12 years*
doreto is offline   Reply With Quote
Old 15/02/2012, 05:27 PM   #8
KingHual
Banned
 
Join Date: Jun 2010
Location: Bulgaria
Posts: 2,297
Reputation: 1389
Default Re: Mysql GetPlayerIP something wrong

Yes, the variable Query has already been defined ...
KingHual is offline   Reply With Quote
Old 15/02/2012, 05:39 PM   #9
doreto
High-roller
 
doreto's Avatar
 
Join Date: Aug 2010
Posts: 1,667
Reputation: 118
Default Re: Mysql GetPlayerIP something wrong

if i remove new Query[100]; from register dialog its show
PHP Code:
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase

Header size
:           2696 bytes
Code size
:            33520 bytes
Data size
:            21912 bytes
Stack
/heap size:      16384 bytesestimated maxusage=14156 cells (56624 bytes)
Total requirements:   74512 bytes 
and give error and cant connect to db
__________________
Quote:
Originally Posted by Kalcor View Post
This my site, so I get to decide what links are allowed. utube and 1e100 are no longer part of my web of trust.

The internet is more important to me than sa-mp. You don't get sa-mp without the internet.
Quote:
Originally Posted by [Twixx] View Post
That's kind of hypocritical of you to say. Sure you own the website, but it's not your personal blog or something - it's a community driven forum. The community should be the primary focus, not your personal agendas. Just like you don't get SA-MP without internet, you don't get SA-MP forums without community.

Just wiping out years worth of people's work and creations posted on that board because a bunch of people bypassed your Tube ban is absurd.
Quote:
Originally Posted by Mauzen View Post
"tube sucks cause they delete 6 years old videos for no reason!"

*deletes every single video ever posted here in 12 years*
doreto is offline   Reply With Quote
Old 15/02/2012, 05:49 PM   #10
kirk
Huge Clucker
 
Join Date: Oct 2010
Posts: 221
Reputation: 75
Default Respuesta: Mysql GetPlayerIP something wrong

Name it rQuery, for example, the one you removed as it seems you alredy defined a global variable called Query.
kirk is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrong values - MySQL -Prodigy- Scripting Help 4 06/01/2012 12:13 PM
MySQL Query gone wrong. Toni Help Archive 2 31/10/2010 07:50 AM
MySql Error, Don't know what is wrong nutzkung69 Help Archive 0 25/07/2009 03:17 PM
How am I doing this wrong? MySQL NovaParadox Help Archive 2 01/02/2009 10:50 PM


All times are GMT. The time now is 04:34 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.