01.02.2013, 16:16
Hello.
Question 1:
I want to ask you if there's fast another way for this script code:
Question 2:
What are the diffrences on "SELECT" in this ways, and how can I use the results of the way: "SELECT `Key1`, `Key2`..."
Way 1:
Way 2:
What is better and how can I use the way 1? how can I take the results of Key1, Key2.
Thanks.
Question 1:
I want to ask you if there's fast another way for this script code:
pawn Code:
if(!strcmp(cmd, "/find", true))
{
new Float:VPos[3];
cmd = strtok(cmdtext, idx);
format(query, sizeof(query), "SELECT `Spawn` FROM `cars` WHERE `CarID`='%d' AND `Owner`='%s'", strval(cmd), Name(playerid));
mysql_query(query);
mysql_store_result();
new values = mysql_fetch_int();
if(values != -1)
{
GetVehiclePos(values, VPos[0], VPos[1], VPos[2]);
SetPlayerCheckpoint(playerid, VPos[0], VPos[1], VPos[2], 2);
}
else SendClientMessage(playerid, White, "You're vehicle isn't spawned yet.");
mysql_free_result();
return true;
}
What are the diffrences on "SELECT" in this ways, and how can I use the results of the way: "SELECT `Key1`, `Key2`..."
Way 1:
pawn Code:
format(query, sizeof(query), "SELECT `Key1`, `Key2` FROM `folder` WHERE `User`='%s'", GetName(playerid));
pawn Code:
format(query, sizeof(query), "SELECT * FROM `users` WHERE `User`='%s'", GetName(playerid));
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query, "|"))
{
mysql_fetch_field_row(loadstr[0], "Key1");
mysql_fetch_field_row(loadstr[1], "Key2");
mysql_fetch_field_row(loadstr[2], "Key3");
PlayerSystem[playerid][Key1] = strval(loadstr[1]);
PlayerSystem[playerid][Key2] = strval(loadstr[2]);
PlayerSystem[playerid][Key3] = strval(loadstr[3]);
}
mysql_free_result();
Thanks.