Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help mysql Database
#1
Hi, i'm trying to change the way my server saves info to a database instead of a txt file due to the large amount of files.

currently below is how weapons etc are bought. Need direction to change checking points in database and deducting from ammount.


int points = (int)Points[Client.XUID];

//Secondarys
string SCORPACost = GetServerCFG("shop", "SCORPACost", "");
etc

if (Message == "!17")
{

int mp7Cost2 = Convert.ToInt32(mp7Cost);
if ((int)Points[Client.XUID] < mp7Cost2) <<<< how to check in data base ?
{
iPrintLnBold("^1Not enough points!", Client);
}
else
{
int WepID = GetWeapon("iw5_mp7_mp_reflexsmg_camo03");
Client.Other.PrimaryWeapon = WepID;
Client.Other.CurrentWeapon = WepID;
Client.Ammo.PrimaryAmmoClip = 140;
Client.Ammo.PrimaryAmmo = 50;
Client.Ammo.EquipmentAmmo = 1;
Client.Ammo.OffhandAmmo = 1;
Points[Client.XUID] = ((int)Points[Client.XUID]) - mp7Cost2; <<<<<<<<<<<< hw to deduct from database?
}

return ChatType.ChatNone;
}


I have already setup a hud for points which works. Help appreciated

creds
@Sailormoon for original code
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#2
UPDATE players SET points = WHATEVER POINTS WHERE playerID = THEPLAYERID.
Reply

#3
I can easily get it to remove the points trouble i'm having is the code to actually check that the player has enough points to start with to buy the weapons
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#4
You could just decrease the points from the dictionary/hashtable and update the points in the database in OnPlayerDisconnect so you don't have to check anything in the DB, if you meant that
Reply

#5
if (Message == "!shield")
{
if (hud.Client_HudElem_Points.ContainsKey(Client.ClientNum)) << How do i check here that they have enough points to start with in the points/hud
{
iPrintLnBold("^12000 POINTS Needed!", Client);
}
else
{



iPrintLnBold("^3You've bought a Shield!", Client);
int WepID = GetWeapon("iw5_riotshieldjugg_mp");
// int WepID1 = GetWeapon("iw5_riotshieldjugg_mp");
Client.Other.Equipment = WepID;
Client.Other.MaxHealth = 300;
Client.Other.Health = 300;
Client.Other.SecondaryWeapon = WepID;
Client.Other.SpeedScale = 1.4f;
//Client.Ammo.OffhandAmmo = 1;
Client.Ammo.EquipmentAmmo = 1;
// UpdatePoints(-2000, Client);
UpdatePoints(Statistics.KILL_POINTS_AXIS, Client); <<<<Removes points from hud or UpdatePoints(-2000, Client);

}
return ChatType.ChatNone;
}

or am i going around this the wrong way via UpdatePoints(Statistics.KILL_POINTS_AXIS, Client); <<<<Removes points from hud
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#6
hud.Client_HudElem_Points[C.XUID].Value ?
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#7
Thanks but i messed it up lol and can't be arsed to do it again.
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#8
(05-31-2013, 02:27)hillbilly Wrote: Thanks but i messed it up lol and can't be arsed to do it again.
I can help you just tell me that I do not want to see all the code! Troll (my code its secret)
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Storing data in a database shanky 3 3,060 10-16-2013, 01:37
Last Post: yokai134
Question Help Upgrade my point system from files to Database, help? EnVi Sweden Rocks 11 9,439 08-03-2013, 23:31
Last Post: EnVi Sweden Rocks
  Shop Database Hallla 5 4,803 07-23-2013, 07:33
Last Post: xfxtroll
  shop mySQL [HARD] Tony. 3 2,646 03-19-2013, 17:13
Last Post: [HARD] Tony.
  Help Mw3 Shop with points + Database 99IRock 2 3,156 12-09-2012, 22:21
Last Post: 99IRock

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.