SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 24/01/2018, 06:42 AM   #1
Jokers98s
Big Clucker
 
Join Date: Jul 2017
Posts: 110
Reputation: 9
Default IP is not got from MYSQL DB

To ban an player offline

used cache_get_value_name too but still the value of the targetip is null
PHP Code:
CMD:oban(playeridparams[])
{
    if(
pInfo[playerid][AdminLvl] < 1) return -1
    if(
pInfo[playerid][AdminLvl] >= 4
    {
        new 
target[MAX_NICK_LENGTH 1], reason[50], time;
        if(
sscanf(params"s[20]dS(No reason given)[50]"targettimereason)) return SendClientMessage(playeridCOLOR_RED"USAGE: /oban [NAME] [DAYS] [REASON]") ;
        if(
time || time 365) return SendClientMessage(playeridCOLOR_RED"ERROR: "COL_GREY"Invalid ban time, must be between 0 ~ 365 (0 = permanent ban).") ;

        new 
query[65];

        
mysql_format(gSQLquerysizeof query"SELECT * FROM `Users` WHERE `Name` = '%e'"target);
        if(
mysql_tquery(gSQLquery"OnAccountExist""i"playerid))
        {
            new 
str[144], expiretime = (gettime() + (((time 24) * 60) * 60));
            if(
time 0format(strsizeof str"* ADMIN %s has offline banned %s for \"%s\" till %s."pName[playerid], targetreasonReturnDate(expiretime));
            else 
format(strsizeof str"* ADMIN %s has permanently offline banned %s for \"%s\"."pName[playerid], targetreason);
            
SendClientMessageToAll(COLOR_PINKstr);
            
mysql_format(gSQLquerysizeof(query), "SELECT * FROM `Users` WHERE `Name` = '%s'"target);
            
mysql_tquery(gSQLquery);
            new 
targetip[12];
            
cache_get_value(0"IP"targetip);
            
SendClientMessage(playerid,COLOR_RED,targetip);
            
OfflineBanPlayer(targetiptargetpName[playerid], reason, (!time) ? expiretime);
        }
        else
        {
            
SendClientMessage(playeridCOLOR_RED"ERROR: "COL_GREY"That account doesn't exist.");    
        }
    } 
Jokers98s is offline   Reply With Quote
Old 24/01/2018, 10:56 AM   #2
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,915
Reputation: 258
Default Re: IP is not got from MYSQL DB

mysql_tquery: Sends a query which will be executed in another thread and call a callback (if there was one specified) when the execution is successfully finished. - click here
mysql_query: This native sends a non-threaded query to the MySQL server. The SA:MP server (the main PAWN thread) waits until the query has been executed and then returns the stored cache handle. - Click here

Simply use mysql_query (don't forget to delete cache when you don't code anymore to treated) or create public forwarded functions with your actually code.
__________________
actor_plus - v5.0.2
I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath
Dayrion is offline   Reply With Quote
Old 24/01/2018, 10:59 AM   #3
Meller
Banned
 
Join Date: Dec 2016
Posts: 578
Reputation: 132
Default Re: IP is not got from MYSQL DB

also, an ip can extend up to 16.

255.255.255.255 = (3*4)+3 = 15 + 1 ( for \0 )
Meller is offline   Reply With Quote
Old 24/01/2018, 12:10 PM   #4
Jokers98s
Big Clucker
 
Join Date: Jul 2017
Posts: 110
Reputation: 9
Default Re: IP is not got from MYSQL DB

Sorry got my mistake thanks rep++ for both
Jokers98s 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
MySQL Plugin r39-2 Error: Can't connect to local MySQL server through socket Emre__ Scripting Help 10 30/07/2014 08:26 AM
[Tutorial] [VIDEO] MySQL ORM r38: How to pair GM with MySQL & creation of registration/connection system cArnasLT Tutorials 3 19/05/2014 02:08 PM
BlueG MySQL plugin - Failed (plugins/mysql.so: undefined symbol: _Z13stringvprintfPKcPc) linuxthefish Plugin Development 10 13/07/2013 10:56 AM
[Tool/Web/Other] MySQL DB Manager - Easily manage your MySQL databases with this remote application fiki574 Tools and Files 13 22/07/2012 09:41 AM


All times are GMT. The time now is 12:22 PM.


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