31.12.2011, 06:43
Well, I've got this FS and it is crashing the server. Everything works fine for the first couple of minutes, and then the server crashes. What could be the cause? Is it LoadFSPlayer()?
Please, I would appreciate it.
pawn Код:
#include <a_samp>
#include <dini>
//**********************************************************************************
forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
forward PlayerActionMsg(playerid, string[]);
forward WorkingOut(playerid);
forward LoadFSPlayer(playerid);
forward UnloadFSPlayer(playerid);
//****DEFINES***********************************************************************
//**********************************************************************************
#define COLOR_PURPLE 0xC2A2DAAA
#define COLOR_RED 0xAA3333AA
//****DIALOGS***********************************************************************
#define WORKOUT_DIALOG 101
//****ENUMS*************************************************************************
enum fspInformation
{
fsFaction
}
new fspInfo[MAX_PLAYERS][fspInformation];
//****OTHER VARIABLES***************************************************************
// SIREN ************************
new sirenid[MAX_VEHICLES];
new sirenvehid[MAX_PLAYERS];
new bool:PlayerUsingSiren[MAX_PLAYERS];
// GYM **************************
new GymIcon;
new WorkoutSaveSkin[MAX_PLAYERS];
new bool:pWorkingOut[MAX_PLAYERS];
new WorkOutTimer[MAX_PLAYERS];
// LEO MASK**********************
new bool:pLeoMask[MAX_PLAYERS];
// LOGIN TIMER*******************
new logintimer[MAX_PLAYERS];
//**********************************************************************************
//**********************************************************************************
//**********************************************************************************
//**********************************************************************************
public OnFilterScriptInit()
{
print("\n****************************************");
print("My Filterscript");
print("****************************************\n");
print("Creating objects...");
CreateObject(7905, 1402.9122314453, 228.22177124023, 28.174299240112, 0, 0, 230);
CreateObject(1267, 1404.4743652344, 225.09881591797, 22.177270889282, 0, 0, 125);
CreateObject(14794, 1410.4654541016, 229.10227966309, -56.568717956543, 0, 0, 246);
CreateObject(1496, 1398.0317382813, 227.26666259766, -58.967788696289, 0, 0, 246);
CreateObject(1496, 1398.03125, 227.2666015625, -61.392860412598, 0, 0, 245.99487304688);
CreateObject(1985, 1410.091796875, 218.65293884277, -55.897777557373, 0, 0, 0);
CreateObject(1985, 1411.0272216797, 220.73614501953, -55.897777557373, 0, 0, 0);
CreateObject(1985, 1414.0927734375, 219.9524230957, -55.897777557373, 0, 0, 0);
CreateObject(1985, 1416.1945800781, 218.99618530273, -55.897777557373, 0, 0, 0);
CreateObject(2630, 1404.8758544922, 237.28793334961, -58.990592956543, 0, 0, 66);
CreateObject(2630, 1402.3126220703, 231.59939575195, -58.990592956543, 0, 0, 65.994873046875);
CreateObject(2628, 1405.6716308594, 240.68487548828, -58.996700286865, 0, 0, 30);
CreateObject(2627, 1403.0733642578, 233.75607299805, -58.990592956543, 0, 0, 245.74996948242);
CreateObject(2627, 1403.8056640625, 235.40005493164, -58.990592956543, 0, 0, 245.74768066406);
CreateObject(2596, 1413.1225585938, 222.41012573242, -55.406589508057, 0, 0, 219);
CreateObject(2629, 1408.3453369141, 234.17785644531, -58.990592956543, 0, 0, 336);
CreateObject(2629, 1410.2454833984, 233.35948181152, -58.990592956543, 0, 0, 335.99487304688);
CreateObject(2632, 1411.5626220703, 237.21682739258, -59.00207901001, 0, 0, 336);
CreateObject(14399, 1406.1463623047, 222.35711669922, -59.215606689453, 0, 0, 335.75);
CreateObject(2190, 1398.8135986328, 227.96144104004, -57.840606689453, 0, 0, 70);
CreateObject(2226, 1406.5264892578, 224.16003417969, -57.840606689453, 0, 0, 120);
CreateObject(4730, 1420.2875976563, 221.29470825195, -57.252502441406, 0, 0, 253.75);
CreateObject(2356, 1399.9520263672, 228.55400085449, -58.990592956543, 0, 0, 130);
CreateObject(14782, 1423.8432617188, 233.47190856934, -57.978652954102, 0, 0, 336.24743652344);
CreateObject(14782, 1422.5515136719, 229.97134399414, -57.978652954102, 0, 0, 245.49206542969);
CreateObject(14791, 1413.3237304688, 227.94110107422, -56.998352050781, 0, 0, 336.25);
GymIcon = CreatePickup(1272, 23, 1400.9493,230.7350,19.5469, -1);
Create3DTextLabel("/workout", 0xA8FF1CAA, 1422.6510,232.6946,-57.9954, 20.00, 10, 0);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
sirenvehid[playerid] = 0;
PlayerUsingSiren[playerid] = false;
pWorkingOut[playerid] = false;
// Load Variables
logintimer[playerid] = SetTimerEx("LoadFSPlayer", 30000, false, "i", playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(IsPlayerInAnyVehicle(playerid)){
new vid;
vid = GetPlayerVehicleID(playerid);
if(sirenid[vid] != 0){
DestroyObject(sirenid[vid]);
sirenid[vid] = 0;
}
}
if(sirenvehid[playerid] != 0)
{
DestroyObject(sirenid[sirenvehid[playerid]]);
sirenvehid[playerid] = 0;
}
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
if(sirenid[vehicleid] != 0){
DestroyObject(sirenid[vehicleid]);
sirenid[vehicleid] = 0;
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/siren", cmdtext, true, 10) == 0)
{
new vehid, modelid;
if(!IsPlayerInAnyVehicle(playerid)) return 1;
if(fspInfo[playerid][fsFaction] == 0 || fspInfo[playerid][fsFaction] == 1){
vehid = GetPlayerVehicleID(playerid);
modelid = GetVehicleModel(vehid);
if(PlayerUsingSiren[playerid] == true){
if(vehid == sirenvehid[playerid]){
DestroyObject(sirenid[vehid]);
sirenid[vehid] = 0;
sirenvehid[playerid] = 0;
PlayerUsingSiren[playerid] = false;
return PlayerActionMsg(playerid, "turns off the emergency lights.");
}
return 1;
}
if(modelid == 426){
sirenid[vehid] = CreateObject( 18646,0,0,0,0,0,0,80 ); // <Premier>
AttachObjectToVehicle( sirenid[vehid], GetPlayerVehicleID(playerid), -0.000000, 0.600000, 0.299999, 0.000000, 0.000000, 0.000000 ); // <Premier>
sirenvehid[playerid] = vehid;
PlayerUsingSiren[playerid] = true;
return PlayerActionMsg(playerid, "turns the emergency lights on.");
}
if(modelid == 402){
sirenid[vehid] = CreateObject( 18646,0,0,0,0,0,0,80 ); // <buffalo z - 0.02>
AttachObjectToVehicle( sirenid[vehid], GetPlayerVehicleID(playerid), 0.000000, 0.600000, 0.200000, 0.000000, 0.000000, 0.000000 ); // <buffalo z - 0.02>
sirenvehid[playerid] = vehid;
PlayerUsingSiren[playerid] = true;
return PlayerActionMsg(playerid, "turns the emergency lights on.");
}
if(modelid == 541){
sirenid[vehid] = CreateObject( 18646,0,0,0,0,0,0,80 ); // <Bullet>
AttachObjectToVehicle( sirenid[vehid], GetPlayerVehicleID(playerid), 0.000000, 0.600000, 0.300000, 0.000000, 0.000000, 0.000000 ); // <Bullet>
sirenvehid[playerid] = vehid;
PlayerUsingSiren[playerid] = true;
return PlayerActionMsg(playerid, "turns the emergency lights on.");
}
if(modelid == 415){
sirenid[vehid] = CreateObject( 18646,0,0,0,0,0,0,80 ); // <Cheetah>
AttachObjectToVehicle( sirenid[vehid], GetPlayerVehicleID(playerid), 0.000000, 0.600000, 0.200000, 0.000000, 0.000000, 0.000000 ); // <Cheetah>
sirenvehid[playerid] = vehid;
PlayerUsingSiren[playerid] = true;
return PlayerActionMsg(playerid, "turns the emergency lights on.");
}
if(modelid == 560){
sirenid[vehid] = CreateObject( 18646,0,0,0,0,0,0,80 ); // <Sultan>
AttachObjectToVehicle( sirenid[vehid], GetPlayerVehicleID(playerid), 0.000000, 0.800000, 0.400000, 0.000000, 0.000000, 0.000000 ); // <Sultan>
sirenvehid[playerid] = vehid;
PlayerUsingSiren[playerid] = true;
return PlayerActionMsg(playerid, "turns the emergency lights on.");
}
if(modelid == 482){
sirenid[vehid] = CreateObject( 18646,0,0,0,0,0,0,80 ); // <Burrito>
AttachObjectToVehicle( sirenid[vehid], GetPlayerVehicleID(playerid), 0.000000, 1.400000, 0.400000, 0.000000, 0.000000, 0.000000 ); // <Burrito>
sirenvehid[playerid] = vehid;
PlayerUsingSiren[playerid] = true;
return PlayerActionMsg(playerid, "turns the emergency lights on.");
}
if(modelid == 562){
sirenid[vehid] = CreateObject( 18646,0,0,0,0,0,0,80 ); // <Elegy>
AttachObjectToVehicle( sirenid[vehid], GetPlayerVehicleID(playerid), 0.000000, 0.600000, 0.400000, 0.000000, 0.000000, 0.000000 ); // <Elegy>
sirenvehid[playerid] = vehid;
PlayerUsingSiren[playerid] = true;
return PlayerActionMsg(playerid, "turns the emergency lights on.");
}
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "[ERROR] You are not a member of RCSD/FBI.");
}
if (strcmp("/enter", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 5, 1400.9493,230.7350,19.5469)){
SetPlayerPos(playerid, 1398.4214,226.2591,-57.9858);
SetPlayerFacingAngle(playerid, 242.3409);
SetPlayerVirtualWorld(playerid, 10); // VIRTUAL WORLD 10
}
}
if (strcmp("/exit", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 5, 1398.4214,226.2591,-57.9858)){
if(pWorkingOut[playerid]) return SendClientMessage(playerid, COLOR_RED, "[ERROR] Please change into regular clothes first.");
SetPlayerPos(playerid, 1400.9493,230.7350,19.5469);
SetPlayerFacingAngle(playerid, 242.1553 + 180);
SetPlayerVirtualWorld(playerid, 0); // VIRTUAL WORLD 0
}
}
/* if (strcmp("/workout", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 5, 1422.6510,232.6946,-57.9954)){ // Gym locker room
if(!pWorkingOut[playerid]){
WorkoutSaveSkin[playerid] = GetPlayerSkin(playerid);
ShowPlayerDialog(playerid, WORKOUT_DIALOG, DIALOG_STYLE_LIST, "Select workout outfit", "1. Boxer (Red shorts)\n2. Boxer (Blue shorts)\n3. Female","Select", "Cancel"); // 80, 81, 226
return 1;
}
SetPlayerSkin(playerid, WorkoutSaveSkin[playerid]);
pWorkingOut[playerid] = false;
KillTimer(WorkOutTimer[playerid]);
return 1;
}
}
*/
/* if (strcmp("/leomask", cmdtext, true, 10) == 0)
{
if(!IsPlayerConnected(playerid)) return 1;
if(fspInfo[playerid][fsFaction] == 0 || fspInfo[playerid][fsFaction] == 1){
if(!pLeoMask[playerid]){
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
ShowPlayerNameTagForPlayer(i, playerid, 0);
}
}
pLeoMask[playerid] = true;
GameTextForPlayer(playerid, "~r~Masked", 1000, 4);
return 1;
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
ShowPlayerNameTagForPlayer(i, playerid, 1);
}
}
pLeoMask[playerid] = false;
GameTextForPlayer(playerid, "~g~Unmasked", 1000, 4);
return 1;
}
else return SendClientMessage(playerid, COLOR_RED, "[ERROR] You are not a member of RCSD/FBI.");
}*/
return 0;
}
// ================================== PROX DETECTOR ===========================================
public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
if(IsPlayerConnected(playerid))
{
new Float:posx, Float:posy, Float:posz;
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
//radi = 2.0; //Trigger Radius
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerPos(i, posx, posy, posz);
tempposx = (oldposx -posx);
tempposy = (oldposy -posy);
tempposz = (oldposz -posz);
//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
{
if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
{
SendClientMessage(i, col1, string);
}
}
else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
{
if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
{
SendClientMessage(i, col2, string);
}
}
else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
{
if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
{
SendClientMessage(i, col3, string);
}
}
else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
{
if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
{
SendClientMessage(i, col4, string);
}
}
else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
{
SendClientMessage(i, col5, string);
}
}
}
}
}//not connected
return 1;
}
public PlayerActionMsg(playerid, string[])
{
new mstring[140];
format(mstring, 140, "* %s %s", RemoveUnderScore(playerid), string);
ProxDetector(25.0, playerid, mstring, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
return 1;
}
stock RemoveUnderScore(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
for(new i = 0; i < MAX_PLAYER_NAME; i++)
{
if(name[i] == '_') name[i] = ' ';
}
return name;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == GymIcon){
GameTextForPlayer(playerid, "~w~Gym: ~y~Train Hard Montgomery\n~w~Owner: ~y~Town of Montgomery\n~w~Entrance Fee: ~y~$0", 1500, 3);
}
return 1;
}
// DIALOG
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == WORKOUT_DIALOG){
switch(listitem) // This is far more efficient than using an if-elseif-else structure
{
case 0: // Listitems start with 0, not 1
{
SetPlayerSkin(playerid, 80);
PlayerActionMsg(playerid, "changes his clothes into workout one.");
}
case 1:
{
SetPlayerSkin(playerid, 81);
PlayerActionMsg(playerid, "changes his clothes into workout one.");
}
case 2:
{
SetPlayerSkin(playerid, 226);
PlayerActionMsg(playerid, "changes her clothes into workout one.");
}
}
pWorkingOut[playerid] = true;
WorkOutTimer[playerid] = SetTimerEx("WorkingOut", 30000, true, "i", playerid);
return 1;
}
return 1;
}
public WorkingOut(playerid)
{
new Float:health;
GetPlayerHealth(playerid, health);
if(health < 95.00){
SetPlayerHealth(playerid, health + 5.00);
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(pWorkingOut[playerid]){
KillTimer(WorkOutTimer[playerid]);
pWorkingOut[playerid] = false;
}
return 1;
}
//***LOAD PLAYER************************************************************************
public LoadFSPlayer(playerid)
{
new usfile[100], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(usfile, sizeof(usfile), "Accounts/%s.ini", pName);
new File:UserFile = fopen(usfile, io_read); // Open the file
new key[256], val[256];
new Data[256];
while (fread(UserFile, Data, sizeof(Data)))
{
key = ini_GetKey(Data);
if(strcmp(key ,"Faction" ,true ) == 0) { val = ini_GetValue(Data); fspInfo[playerid][fsFaction] = strval(val);}
}
fclose(UserFile);
pLeoMask[playerid] = false;
}
//****STOCKS****************************************************************************
stock ini_GetKey( line[] )
{
new keyRes[256];
keyRes[0] = 0;
if ( strfind( line , "=" , true ) == -1 ) return keyRes;
strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
return keyRes;
}
stock ini_GetValue( line[] )
{
new valRes[256];
valRes[0]=0;
if ( strfind( line , "=" , true ) == -1 ) return valRes;
strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
return valRes;
}
//*************************************************************************************