Problem loading object data with y_ini
#1

I have converted this speed camera system from default samp file saving/loading system to Y_INI

Everything works fine, the camera's data are saved in a ini file, but when the gamemode is started, cameras aren't loading, i can still see the saved ini files but they aren't loading ingame. Whats wrong with it?

pawn Код:
CMD:addcam(playerid, params[])
{
    new
        Float:x,
        Float:y,
        Float:z,
        Float:Angle,
        MaxSpeed,
        string[70]
    ;

    if (pInfo[playerid][AdminLevel] < 4)
        return 0;

    if (sscanf(params, "i", MaxSpeed)) return SCM(playerid, GRAY, "Usage: /addcam <Max Speed>");
    if(MaxSpeed > 120 || MaxSpeed < 60) return SCM(playerid, RED, "Please use the Max-Speed between 60 to 120.");
    GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, Angle); z = z - 1.0;
    SetPlayerPos(playerid, x, y + 1.0, z + 1.0);
    for (new CamID; CamID < MAX_CAMERAS; CamID++)
    {
        if (gCameras[CamID][CamSpeed] == 0)
        {
            SetupSpeedCamera(CamID, x, y, z, Angle, MaxSpeed);
            new INI:CamFile = INI_Open(Camera_Path(CamID));
            INI_SetTag(CamFile, "data");
            INI_WriteFloat(CamFile, "CamX", x);
            INI_WriteFloat(CamFile, "CamY", y);
            INI_WriteFloat(CamFile, "CamZ", z);
            INI_WriteFloat(CamFile, "CamAngle", Angle);
            INI_WriteInt(CamFile, "CamSpeed", MaxSpeed);
            INI_Close(CamFile);
            format(string, sizeof(string), "You've created a speed camera with ID: %i.", CamID);
            SCM(playerid, AD_COLOR_ACTION, string);
            SendAdminCmd(playerid, "ADDCAM", params);
            return 1;
        }
    }
    format(string, sizeof(string), "You cannot create more than %i speedcameras.", MAX_CAMERAS);
    SCM(playerid, RED, string);
    return 1;
}

//In OnGameModeInit()
for (new CamID; CamID < MAX_CAMERAS; CamID++)
    if(fexist(Camera_Path(CamID)))
        INI_ParseFile(Camera_Path(CamID), "LoadCamera_%s", .bExtra = true, .extra = CamID);
       
forward LoadCamera_data(CamID, name[], value[]);
public LoadCamera_data(CamID, name[], value[])
{
    new INI:CamFile = INI_Open(Camera_Path(CamID));
    new Float:x, Float:y, Float:z, Float:rot, MaxSpeed;

    INI_Float("CamX", x);
    INI_Float("CamY", y);
    INI_Float("CamZ", z);
    INI_Float("CamAngle", rot);
    INI_Int("CamSpeed", MaxSpeed);
    INI_Close(CamFile);
    SetupSpeedCamera(CamID, x, y, z, rot, MaxSpeed);
    TotalCameras++;
    return 1;
}

stock Camera_Path(CamID)
{
    new string[40];
    format(string, sizeof(string), "/Cameras/Cam%i.ini", CamID);
    return string;
}

SetupSpeedCamera(CamID, Float:x, Float:y, Float:z, Float:rot, MaxSpeed)
{
    gCameras[CamID][CamX] = x;
    gCameras[CamID][CamY] = y;
    gCameras[CamID][CamZ] = z;
    gCameras[CamID][CamAngle] = rot;
    gCameras[CamID][CamSpeed] = MaxSpeed;
    gCameras[CamID][CamObj1] = CreateDynamicObject(3335, x, y, z, 0.0, 0.0, rot);
    gCameras[CamID][CamObj2] = CreateDynamicObject(3335, x, y, z, 0.0, 0.0, rot + 180.0);
    new cam_text[50];
    format(cam_text, sizeof(cam_text), "Slow down!\nMax Speed: %i KPH", MaxSpeed);
    gCameras[CamID][SpeedText] = Create3DTextLabel(cam_text, YELLOW,  x, y, z + 2.3, 80.0,0);
}
Someone please help fast, i need to fix this asap.
Reply


Messages In This Thread
Problem loading object data with y_ini - by iOxide - 09.09.2014, 15:05
Re: Problem loading object data with y_ini - by iOxide - 10.09.2014, 20:31
Re: Problem loading object data with y_ini - by Lordzy - 11.09.2014, 05:28
Re: Problem loading object data with y_ini - by iOxide - 11.09.2014, 11:11
Re: Problem loading object data with y_ini - by iOxide - 12.09.2014, 06:47
Re: Problem loading object data with y_ini - by Stinged - 12.09.2014, 07:15
Re: Problem loading object data with y_ini - by iOxide - 12.09.2014, 07:21

Forum Jump:


Users browsing this thread: 2 Guest(s)