-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.pwn
114 lines (89 loc) · 3.62 KB
/
test.pwn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// generated by "sampctl package generate"
#include <a_samp>
#include <a_mysql>
#include <YSI_Coding\y_va>
#include <YSI_Coding\y_inline>
#include "mysql_prepared"
new MySQL:MySQLHandle;
new
Statement:stmt_readone;
main() {
MySQLHandle = mysql_connect("localhost", "root", "", "cnr");
mysql_log(ALL);
mysql_pquery(MySQLHandle, "CREATE TABLE IF NOT EXISTS accounts(\
username VARCHAR(24) NOT NULL, \
password VARCHAR(65) NOT NULL, \
salt VARCHAR(11) NOT NULL, \
money INT(11), \
kills, INT(11), \
deaths INT(11))");
new Statement: stmt_insert = MySQL_PrepareStatement(MySQLHandle, "INSERT INTO accounts(username, password, salt, money, kills, deaths) VALUES (?,?,?,?,?,?) " );
// Arrow values in questions (first 0, second is 1, etc ...)
MySQL_Bind(stmt_insert, 0 , "patrickgtr");
MySQL_Bind(stmt_insert, 1 , "patrickgtrpassword");
MySQL_Bind(stmt_insert, 2 , "pgtrhash");
MySQL_BindInt(stmt_insert, 3, 100);
MySQL_BindInt(stmt_insert, 4, 200);
MySQL_BindInt(stmt_insert, 5, 300);
MySQL_ExecuteParallel(stmt_insert);
MySQL_StatementClose(stmt_insert);
stmt_readone = MySQL_PrepareStatement(MySQLHandle, "SELECT username, password, salt, money, kills, deaths FROM accounts where username = ?");
new Statement:stmt_readloop = MySQL_PrepareStatement(MySQLHandle, "SELECT * FROM spawns");
// Run Threaded on statement
inline OnSpawnsLoad() {
new
spawnID,
Float:spawnX,
Float:spawnY,
Float:spawnZ,
Float:spawnA;
MySQL_BindResultInt(stmt_readloop, 0, spawnID);
MySQL_BindResultFloat(stmt_readloop, 1, spawnX);
MySQL_BindResultFloat(stmt_readloop, 2, spawnY);
MySQL_BindResultFloat(stmt_readloop, 3, spawnZ);
MySQL_BindResultFloat(stmt_readloop, 4, spawnA);
while(MySQL_Statement_FetchRow(stmt_readloop)) {
printf("%i, %.3f, %.3f, %.3f", spawnID, spawnX, spawnY, spawnZ, spawnA);
}
MySQL_StatementClose(stmt_readloop);
}
MySQL_ExecuteThreaded_Inline(stmt_readloop, using inline OnSpawnsLoad);
SetTimerEx("Emulate_OnPlayerConnect", 2000, false, "i", 0);
}
forward Emulate_OnPlayerConnect(playerid);
public Emulate_OnPlayerConnect(playerid) {
printf("OPC, playerid: %i", playerid);
MySQL_Bind(stmt_readone, 0, "patrickgtr");
MySQL_ExecuteThreaded(stmt_readone, "OnPlayerLoad", "isf", playerid, "Hello World;", 192.168);
return 1;
}
forward OnPlayerLoad(playerid,const fmat[], Float:pos);
public OnPlayerLoad(playerid, const fmat[], Float:pos)
{
printf("OnPlayerLoad, playerid: %i", playerid);
printf("OnPlayerLoad, fmat: %s", fmat);
printf("OnPlayerLoad, pos: %.4f", pos);
new
playerUsername[MAX_PLAYER_NAME],
playerPassword[65],
playerSalt[11],
playerMoney,
playerKills,
playerDeaths;
// retrieve
MySQL_BindResult(stmt_readone, 0, playerUsername, sizeof(playerUsername));
MySQL_BindResult(stmt_readone, 1, playerPassword, sizeof(playerPassword));
MySQL_BindResult(stmt_readone, 2, playerSalt, sizeof(playerSalt));
MySQL_BindResultInt(stmt_readone, 3, playerMoney);
MySQL_BindResultInt(stmt_readone, 4, playerKills);
MySQL_BindResultInt(stmt_readone, 5, playerDeaths);
if(MySQL_Statement_FetchRow(stmt_readone)) {
printf("username %s", playerUsername);
printf("password %s", playerPassword);
printf("salt %s", playerSalt);
printf("money %i", playerMoney);
printf("kills %i", playerKills);
printf("deaths %i", playerDeaths);
}
MySQL_StatementClose(stmt_readone);
}