SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 13/06/2018, 12:17 AM   #1
nbx2000
Big Clucker
 
Join Date: Dec 2016
Posts: 67
Reputation: 0
Default Mysql cmd admin error

problem cmd admin to sell house is not updated to zero value hID on the table mysql en phpmyadmin

Code:
CMD:asellh(playerid,params[]) {
  if(PlayerInfo[playerid][Level] >= 6) {
    new i;
    i = GetHouseID(playerid);
    if(i == -255) return SendClientMessage(playerid, 0xDC143CAA, "ERROR: You need to be on house icon to remove it");
    new Query[128],string[128];
    format(Query, sizeof(Query), "UPDATE `houses` SET `Owner` = '%s', `Owned` = '%d'  WHERE `ID` = '%d'","NULL",0,HouseInfo[i][Houseid]);
    mysql_tquery(mysql, Query, "", "");
    if(HouseInfo[i][Owned] == 1) {
    HERE!  format(Query, sizeof(Query),"UPDATE `accounts` SET `hID` = 0,`HOwned` = 0 WHERE `Name` = '%s'",pName(playerid));HERE 
      mysql_tquery(mysql, Query, "", "");
      foreach (new i2 : Player) {
	     if(IsPlayerConnected(i2)) {
           if(strcmp(HouseInfo[i][Owner],pName(i2),false )== 0) {
               PlayerInfo[i2][hOwned] = 0;
			   PlayerInfo[i2][hID] = 0;
               format(string,sizeof string,"Administrator %s Has Reseted Your House",pName(playerid));
               SendClientMessage(i2,0x33AA33AA,string);
           }
	    }
      }
    }
    HouseInfo[i][Owned] = 0;
	strmid(HouseInfo[i][Owner],"NULL", 0, strlen("NULL"), 255);
    DestroyDynamicPickup(HousePickup[i]);
    HousePickup[i] = CreateDynamicPickup(1273, 23, HouseInfo[i][HX], HouseInfo[i][HY], HouseInfo[i][HZ]);
    UpdateDynamic3DTextLabelText(hTextInfo[i],0x00FF00FF,"Not Owned");
    DestroyDynamicMapIcon(housemapicon[i]);
    housemapicon[i] = CreateDynamicMapIcon(HouseInfo[i][HX], HouseInfo[i][HY], HouseInfo[i][HZ],31,c_y);
    format(string,sizeof string,"You've Successfully Sold This house [ ID: %d ]",i);
    SendClientMessage(playerid, 0x33AA33AA, string);
	format(string,sizeof string,"Administrator %s(IP: %s) Has Rested House ID: %d",pName(playerid),pIP(playerid),i);
	SaveToFile("resetlog",string);
    MessageToAdmins(red ,string);
   } else return SendClientMessage(playerid, 0xDC143CAA, "ERROR: You need to be rcon to use this command");
  return 1;
}
Attached Images
File Type: png 543.PNG (2.6 KB, 9 views)

Last edited by nbx2000; 13/06/2018 at 02:09 AM.
nbx2000 is offline   Reply With Quote
Old 13/06/2018, 12:26 AM   #2
JasonRiggs
Gangsta
 
Join Date: Jul 2016
Location: My bedroom.
Posts: 744
Reputation: 39
Default Re: Mysql cmd admin error

Show us the mysql_log to know the exact problem.
__________________


Discord: Riggs #5210
JasonRiggs is offline   Reply With Quote
Old 13/06/2018, 02:08 AM   #3
nbx2000
Big Clucker
 
Join Date: Dec 2016
Posts: 67
Reputation: 0
Default Re: Mysql cmd admin error

Quote:
Originally Posted by JasonRiggs View Post
Show us the mysql_log to know the exact problem.
the problem is the command when using the sell house command do not change the value to 0 hID

clean mysql log
nbx2000 is offline   Reply With Quote
Old 13/06/2018, 03:01 AM   #4
Slawi
Big Clucker
 
Join Date: Dec 2013
Posts: 47
Reputation: 1
Default Re: Mysql cmd admin error

Check the column if it is correct (Name) and table (accounts)
Slawi is offline   Reply With Quote
Old 13/06/2018, 07:08 AM   #5
Calisthenics
Huge Clucker
 
Join Date: May 2018
Posts: 273
Reputation: 48
Default Re: Mysql cmd admin error

Bad design. Your tables have duplicates.

Table "accounts" should have only the main data of player (id, name, ip, password etc.)

Table "houses" is enough for you to extract data only once and having the same data on another table is not good.

Column "Owner" should have been an integer (userid) and be a FOREIGN KEY to link the two tables. Using JOINs, you can retrieve name of owner and/or which house (if any) the player owns upon logging in.
Calisthenics is offline   Reply With Quote
Old 13/06/2018, 08:53 AM   #6
GTLS
Gangsta
 
GTLS's Avatar
 
Join Date: Aug 2014
Location: India
Posts: 821
Reputation: 91
Default Re: Mysql cmd admin error

This is Jlalt's House system i guess? Log in to your phpmyadmin and make sure, ID column is set to Auto Increment and Primary Key.
__________________

I don't help for rep. I help cuz I was helped in the past.


California State Roleplay - X Update Now under beta testing phase. Stay Tuned.
GTLS 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 Admin [S-G]Cypher Scripting Help 2 28/12/2014 12:58 PM
MySQL Plugin r39-2 Error: Can't connect to local MySQL server through socket Emre__ Scripting Help 10 30/07/2014 08:26 AM
Mysql queriesYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for th audriuxxx Scripting Help 4 11/04/2014 06:42 PM
Mysql PHP MY ADMIN firemanjv Scripting Help 0 04/07/2012 08:09 AM
Admin with MYSQL AlExAlExAlEx Help Archive 4 13/02/2011 06:35 PM


All times are GMT. The time now is 12:07 AM.


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