21.09.2012, 09:15
Hi,
After I saw many guys try to convert their gamemodes to Mysql i decide to make their work easier, with regex.
http://gta-mp.ro/tools/mysqlgf
Source:
If you have something else than format(var, 32, "AccLocked=%d\n",PlayerInfo[playerid][pLocked]);fwrite(hFile, var); post here.
PS:
http://gta-mp.ro/tools/usefultools
http://gta-mp.ro/tools/ids
After I saw many guys try to convert their gamemodes to Mysql i decide to make their work easier, with regex.
http://gta-mp.ro/tools/mysqlgf
Source:
PHP код:
<?php
if(isset($_POST['document']))
{
//format(var, 32, "AccLocked=%d\n",PlayerInfo[playerid][pLocked]);fwrite(hFile, var);
preg_match_all("/format\(.*?\"(.*?)=\%(.*?)\\\\.*?PlayerInfo\[playerid\]\[(.*?)\]/", $_POST['document'], $matches, PREG_SET_ORDER);
echo '<pre>';
//print_r($matches);
echo '</pre>';
echo '<pre style="height: 200px;overflow: scroll;background: #EEE;">CREATE TABLE users(<br> id INT PRIMARY KEY AUTO_INCREMENT,<br> Name varchar(50)';
foreach ($matches as $val) {
switch($val[2])
{
case 'd': $fworld = ' INT DEFAULT \'0\'';break;
case 'i': $fworld = ' INT DEFAULT \'0\'';break;
case '.1f': $fworld = ' INT DEFAULT \'0\'';break;
case 's': $fworld = ' varchar(50) DEFAULT \'NaN\'';break;
}
echo ',<br>`'.$val[1].'`'.$fworld;
//echo $matches[0].'<br>';
//echo $matches[1].'<br>';
//echo $matches[2].'<br>';
}
echo ');</pre><p class="itemer">OnPlayerRegister</p>';
echo '<p>ATENTIE,aveti in gamemode niste variabile care au o valoare de baza diferita de 0(cum ar fi CarLicense,CarKey,FMember).Va rugam sa le cautati la OnPlayerConnect si sa le specificati mai jos,ca exemplu fiind DonateRank</p>';
echo '<pre style="height: 200px;overflow: scroll;background: #EEE;">
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
new Str[ 200 ];
new cleanpassword[124];
mysql_real_escape_string(password,cleanpassword);
format(Str, 200 ,"INSERT INTO `users` (`Name`,`Key`,`DonateRank`) VALUES (\'%s\',\'%s\',\'2\');",id,playername3,cleanpassword);
mysql_query(Str);</pre>';
echo '<p class="itemer">OnPlayerLogin</p>';
echo '<pre style="height: 200px;overflow: scroll;background: #EEE;">
new playername2[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
new qstr[100];
new result[100];
new cleanpassword[124];
mysql_real_escape_string(password,cleanpassword);
format(qstr,100,"SELECT * FROM `users` WHERE `Name`=\'%s\' AND `Key`=\'%s\' LIMIT 1",playername2,cleanpassword);
mysql_query(qstr);
mysql_store_result();
if(mysql_num_rows())
{
if(mysql_retrieve_row())
{
';
//mysql_fetch_field_row(result,"Level"); PlayerInfo[playerid][pLevel] = strval( result );
foreach ($matches as $val) {
switch($val[2])
{
case 'd': $fworld = 'PlayerInfo[playerid]['.$val[3].'] = strval( result );';break;
case 'i': $fworld = 'PlayerInfo[playerid]['.$val[3].'] = strval( result );';break;
case '.1f': $fworld = 'PlayerInfo[playerid]['.$val[3].'] = floatstr( result );';break;
case 's': $fworld = 'strmid(PlayerInfo[playerid]['.$val[3].'], result, 0, strlen(result)-1, 255);';break;
}
echo '<br>mysql_fetch_field_row(result,"'.$val[1].'");'.$fworld;
}
echo '
}
}</pre>';
echo '<p class="itemer">OnPlayerUpdate</p>';
echo '<pre style="height: 200px;overflow: scroll;background: #EEE;">';
foreach ($matches as $val) {
switch($val[2])
{
case 'd': $fworld = 'PlayerInfo[playerid]['.$val[3].'] = strval( result );';break;
case 'i': $fworld = 'PlayerInfo[playerid]['.$val[3].'] = strval( result );';break;
case '.1f': $fworld = 'PlayerInfo[playerid]['.$val[3].'] = floatstr( result );';break;
case 's': $fworld = 'strmid(PlayerInfo[playerid]['.$val[3].'], result, 0, strlen(result)-1, 255);';break;
}
//format(var, 62, "UPDATE `users` SET `Key`='%s' WHERE `name`='%s'", PlayerInfo[playerid][pKey],playername3); mysql_query(var);
echo '<br>format(var, 124,"UPDATE `users` SET `'.$val[1].'`=\'%'.$val[2].'\' WHERE `name`=\'%s\'",PlayerInfo[playerid]['.$val[3].'],playername3);mysql_query(var);';
}
echo '</pre>';
}
?>
</p>
PS:
http://gta-mp.ro/tools/usefultools
http://gta-mp.ro/tools/ids