This simple code crashes pawno....
Код:
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT
#include <a_samp>
new Float:pos[MAX_PLAYERS][3];
new Float:price = 0.925; // Price per KM
new Float:dist[MAX_PLAYERS];
new tim[MAX_PLAYERS];
forward tim(playerid);
public tim(playerid)
{
if (!IsPlayerConnected(playerid)) return 0;
new Float:px, Float:py, Float:pz;
GetPlayerPos(playerid, px, py, pz);
new Float:km = (floatsqroot( (px-pos[playerid][0])*(px-pos[playerid][0]) ) + ( (py-pos[playerid][1])*(py-pos[playerid][1]) ) + ( (pz-pos[playerid][2])*(pz-pos[playerid][2]) ) ) / 1000;
pos[playerid][0] = px; pos[playerid][1] = py; pos[playerid][2] = pz;
dist[playerid] = dist[playerid] + km;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp(cmdtext, "/start"))
{
GetPlayerPos(playerid, pos[playerid][0], pos[playerid][1], pos[playerid][2]);
dist[playerid] = 0.0;
tim[playerid] = SetTimerEx("tim", 5000, 1, "d", playerid);
new msg[92];
format(msg, sizeof(msg), "* Az utazбs megkezdődцtt %f $-os KM-enkйnti бrral!", price);
return SendClientMessage(playerid, 0xffff00ff, msg);
}
if (!strcmp(cmdtext, "/stop"))
{
KillTimer(tim[playerid]);
new Float:px, Float:py, Float:pz;
GetPlayerPos(playerid, px, py, pz);
new Float:km = (floatsqroot( ( (px-pos[playerid][0])*(px-pos[playerid][0]) ) + ( (py-pos[playerid][1])*(py-pos[playerid][1]) ) + ( (pz-pos[playerid][2])*(pz-pos[playerid][2]) ) )) / 1000;
km = km + dist[playerid];
new msg[92];
new myprice = floatround(price * km);
dist[playerid] = 0.0;
format(msg, sizeof(msg), "* Az utazбs vйget йrt! %0.3f KM-t utaztбl, ez %d $-ba kerьlt neked!", km, myprice);
return SendClientMessage(playerid, 0xffff00ff, msg);
}
if (!strcmp(cmdtext, "/price", true, 6))
{
if (cmdtext[6] != ' ') return SendClientMessage(playerid, 0xff0000ff, "* Hasznбlat: /price [бr / km]");
new msg[92];
format(msg, sizeof(msg), "* Az ъj fuvar бr: %f $ / km!", floatstr(cmdtext[7]));
SendClientMessageToAll(0xffff00ff, msg);
price = floatstr(cmdtext[7]);
return 1;
}
return 0;
}
Problem solved. Problem was: "tim" was a variable and a function name too... and this caused crash in the "new Float:km = ..." section....