[sscanf] pawn to php -
None1337 - 23.08.2018
So, i'm working on a special quest on my server and also, and i need to take some object id from database, in pawn i know how to do it, but in php i don't really know..
I'm using for my gamemode sscanf, something like this:
Код:
new show_s[300], var_storage[50];
cache_get_field_content(0, "ObjectID", show_s);
sscanf(show_s, "a<i>[50]", var_storage);
How can I do the code above in php language? Can someone help me?
Thanks.
Re: [sscanf] pawn to php -
coool - 23.08.2018
http://php.net/manual/en/function.sscanf.php
Re: [sscanf] pawn to php -
OneDay - 23.08.2018
Don't put all them in one column, use a new table.
Re: [sscanf] pawn to php -
None1337 - 24.08.2018
Quote:
Originally Posted by coool
|
and how can I use this? can you make an example please?
Re: [sscanf] pawn to php -
None1337 - 24.08.2018
Quote:
Originally Posted by ******
Why are you splitting up strings coming from a database in the first place?
|
Because I'm working on a quest (finding objects), and I want to make a San Andreas Map in php to show with a red marker all the object that player has, ex:
https://i.imgur.com/7TC3oyV.jpg (something like that).
And in database i'm saving like that the id
https://imgur.com/a/C0VcmLS
I'm using this function like this to load in a player variables the id of the object id that player has.
Код:
new show_s[300], var_storage[50];
cache_get_field_content(0, "ObjectID", show_s);
sscanf(show_s, "a<i>[50]", var_storage);
I have the coordinates of all objects id, but the problem is that, i don't know how can I make in php to extract from database the object id in a array like function above, but only for php not pawn.
Re: [sscanf] pawn to php -
None1337 - 24.08.2018
Quote:
Originally Posted by ******
Again, why are you storing multiple values in a single column? That's really not how you should be using a database. Make a new table for the object IDs and store one per row.
|
Sorry, my bad. I didn't understand the question.
I already have a table with all objects and x,y,z:
https://imgur.com/a/jmB80p3
So, above is a pictures with all the objects and x,y,z. When a new player register, he got some random objectID from this table, and all the id that player get, i'm saving in a different table.
And i'm using something like that to save the id in database.
Код:
public saveQuest(playerid) {
generateIdRandomFromDb(playerid);
new string[256];
string[0] = (EOS);
for(new x; x < 50; x++) {
format(string, sizeof string, "%s %d", questInfo[playerid][databaseID_object][x]);
}
mysql_format(db, string, sizeof string, "UPDATE `special_table` SET `objectID` = '%e' WHERE `playerID` = %d LIMIT 1;", string, pID[playerid]);
mysql_tquery(db, string);
}
This is the most easier way to do for myself and for the system. Better ways aren't (I think).
And simply, when a player connect, i've loaded his id of an object from database:
Код:
// public LoadQuest (playerid) {
mysql_format(db, Gstring, "SELECt blablabla.... WHERE id .. bla blabla
mysql_tquery(db, Gstrin, bla bla bla..
}
//another public
public finishLoad(playerid) {
if(!cache_num_rows()) return 1;
new show_s[300], var_storage[50];
cache_get_field_content(0, "ObjectID", show_s);
sscanf(show_s, "a<i>[50]", var_storage);
for(new x; x < 50; x++) {
questInfo[playerid][databaseID_object][x] = var_storage[x];
}
}
So every think work perfectly, but i don't know how to store in php the objectID in a array like
$var_storage[x]
to make a loop and create red marker on the San Andreas map.
Re: [sscanf] pawn to php -
CodeStyle175 - 25.08.2018
delete this shit and build new one
modelid
pos0
pos1
pos2
rot0,
rot1,
rot2
Re: [sscanf] pawn to php -
bgedition - 25.08.2018
I have something in mind but for that please answer these questions.
So every player has to find the same objects but in different order?
How many objects are in the database? 50?
Re: [sscanf] pawn to php -
None1337 - 26.08.2018
Quote:
Originally Posted by bgedition
I have something in mind but for that please answer these questions.
So every player has to find the same objects but in different order?
How many objects are in the database? 50?
|
there are 80 objects in total in database.
Players receive a random id from the table, they get only 50 objects id. And they get a random id, like: they can have object 1,2.3...45, and 75..80 = total: 50 objects id. And they must find all the objects in the specified coordinates / of the respective locations (x, y, z) of the object id from the table.