How to get the X, Y, Z floats and set the players position?
#1

Hi,

Im using G-Stylez (I dont know his name so im going to put that) MySQL plugin.
And i have a table on my database with 3 fields, X, Y & ofc Z
How would i get all three coordinates and set the players position to the X, Y, Z, it got?
Reply
#2

You'll need to learn SQL

http://www.w3schools.com/sql/default.asp
Reply
#3

Quote:
Originally Posted by dice7
I know the basic bit, Like how to get one thing, But not all three at once
Reply
#4

Assuming you've set the 3 fields to be 'Floats' and not 'Ints' then it should go like this

You'd save it like this
pawn Код:
new Float:x,Float:y,Float:z,query[64],pname[24];
GetPlayerPos(playerid,x,y,z);
GetPlayerName(playerid,pname,24);
format(query,64,"SELECT * FROM Table WHERE Name='%s' LIMIT 1",pname); //Check to make sure if the row already exists
mysql_query(query);
mysql_store_result();
if(mysql_num_rows()) //Row exists
{
  format(query,64,"UPDATE Table SET X='%f', Y='%f', Z='%f' WHERE Name='%s'",x,y,z,pname);
}else{ //Row doesn't exist
  format(query,64,"INSERT INTO Table (X,Y,Z,Name) VALUES('%f','%f','%f','%s')",x,y,z,pname);
}
mysql_query(query);
To load it you'll need some way to parse the information, using sscanf or the split function will work
Reply
#5

Quote:
Originally Posted by Joe Staff
To load it you'll need some way to parse the information, using sscanf or the split function will work
mysql_retrieve_row() for the win!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)