01.03.2012, 17:47
How to use this include? Can you elaborate please? Thanks for sharing this great include. Seems like a good release.
Originally Posted by FIRST POST
Usage
You just have to add one single line of code after you included a_samp: pawn Code:
|
Your function takes a lot of time to execute. Too much! Even without timerfix, this is a bad thing. What does "Global" do?
|
task Global[1000]()
{
if (sqlx15 == 15)
{
MySQLVerificarConexion();
sqlx15 = 1;
}
else if (sqlx15 > 15) sqlx15 = 1;
else sqlx15++;
foreach(new i: Player)
{
if(InicioCam[i] == 1)
{
LimpiarChat(i);
SetPlayerCameraPos(i, 1349.4004, -880.2820, 52.0618);
SetPlayerCameraLookAt(i, 1350.1967, -879.6675, 52.2867);
SetPlayerPos(i, 1349.4004, -880.2820, 50.0618);
new query[96], rows;
mysql_format(mysql, query, "SELECT Nombre FROM Usuarios WHERE Nombre = '%e'", GetName(i));
mysql_query(query);
mysql_store_result();
rows = mysql_num_rows();
mysql_free_result();
if(rows == 0)
{
DialogoRegistro(i);
}
InicioCam[i] = 0;
}
}
return 1;
}
#define funcion%0(%1) forward%0(%1); public%0(%1)
//...
funcion MySQLVerificarConexion()
{
if(mysql_ping() == 1) return 1;
else
{
print("MYSQL: La conexiуn parece muerta, reintentando...");
mysql_reconnect(mysql);
if(mysql_ping() == 1)
{
print("MYSQL: Conexiуn exitosa. Continuamos de forma normal.");
return 1;
}
else
{
print("MYSQL: No se puede conectar al servidor, terminando servidor...");
SendRconCommand("exit");
return 0;
}
}
}
#include <a_samp>
#include <timerfix>
main() {
SetTimer("TimerFunc", 500, true);
}
forward TimerFunc();
public TimerFunc() {
static
previous_call
;
if (previous_call)
printf("Previous call %dms ago.", GetTickCount() - previous_call);
previous_call = GetTickCount();
}
if(newstate==PLAYER_STATE_DRIVER)
{
speedotimer[playerid] = SetTimerEx("Speedo",200,1,"i",playerid);
}
public Speedo(i)
{
if(IsPlayerInAnyVehicle(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
new iVehicleID = GetPlayerVehicleID(i);
new model = GetVehicleModel(iVehicleID);
if(model ==510 || model==509 || model==481) return 1;
PlayerTextDrawShow(i, textdraws[Textdraw2][i]);
PlayerTextDrawShow(i, textdraws[Textdraw0][i]);
PlayerTextDrawShow(i, textdraws[Textdraw202][i]);
GetVehicleVelocity(GetPlayerVehicleID(i), svx[i], svy[i], svz[i]); // This Saves Our Velocitys To Our Varibles
s10[i] = floatsqroot(((svx[i]*svx[i])+(svy[i]*svy[i]))+(svz[i]*svz[i]))*136.666667; // This Is Our Forumula ( I Don't Know How It Works )
s2[i] = floatround(s10[i],floatround_round); // This Rounds Our Output To The Nearest Whole Number
format(s3[i],30,"SPEED: %iKM/H", s2[i]); // This Format Our Text Into What We See
format(s4[i],30,"FUEL: %iL", VehicleFuel[GetPlayerVehicleID(i)]); // This Format Our Text Into What We See
static string[16];
if(GetVehicleSpeed(iVehicleID) > 10)
{
vInfo[iVehicleID][vMetrai] += floatround(floatdiv(GetVehicleSpeed(iVehicleID), 60.0));
}
if(vInfo[iVehicleID][vMetrai] > 9)
{
vInfo[iVehicleID][vKilometrai] += 1;
vInfo[iVehicleID][vMetrai] = 0;
}
if(arrlen(vInfo[iVehicleID][vKilometrai]) == 1)
{
format(string, 16, "0000%d~r~%d", vInfo[iVehicleID][vKilometrai], vInfo[iVehicleID][vMetrai]);
PlayerTextDrawSetString(i,textdraws[Textdraw202][i], string);
}
else if(arrlen(vInfo[iVehicleID][vKilometrai]) == 2)
{
format(string, 16, "000%d~r~%d", vInfo[iVehicleID][vKilometrai], vInfo[iVehicleID][vMetrai]);
PlayerTextDrawSetString(i,textdraws[Textdraw202][i], string);
}
else if(arrlen(vInfo[iVehicleID][vKilometrai]) == 3)
{
format(string, 16, "00%d~r~%d", vInfo[iVehicleID][vKilometrai], vInfo[iVehicleID][vMetrai]);
PlayerTextDrawSetString(i,textdraws[Textdraw202][i], string);
}
else if(arrlen(vInfo[iVehicleID][vKilometrai]) == 4)
{
format(string, 16, "0%d~r~%d", vInfo[iVehicleID][vKilometrai], vInfo[iVehicleID][vMetrai]);
PlayerTextDrawSetString(i,textdraws[Textdraw202][i], string);
}
else if(arrlen(vInfo[iVehicleID][vKilometrai]) == 5)
{
format(string, 16, "%d~r~%d", vInfo[iVehicleID][vKilometrai], vInfo[iVehicleID][vMetrai]);
PlayerTextDrawSetString(i,textdraws[Textdraw202][i], string);
}
PlayerTextDrawSetString(i,textdraws[Textdraw0][i], s3[i]); // This Changes The Value Of Our Textdraw To What We Formatted
PlayerTextDrawSetString(i,textdraws[Textdraw2][i], s4[i]); // This Changes The Value Of Our Textdraw To What We Formatted
return 1;
}
return 1;
}
[15:41:40] (TimerFix) ERROR: The function "Speedo" didn't properly execute, some timers might not have been called. |