16.11.2013, 22:04
(
Последний раз редактировалось maximthepain; 17.11.2013 в 13:42.
)
Hi!
I want make system to save speed cameras which made in game with command.
When I tried making the system it didn't save the speed cameras after deploying them & doing saving command.
Look at saving progress:
"LoadCams()" under OnGameModeInit.
Deploying Cam:
Why doesn't the saving work? Please help, thanks
I want make system to save speed cameras which made in game with command.
When I tried making the system it didn't save the speed cameras after deploying them & doing saving command.
Look at saving progress:
Код:
#define MAX_CAMS 20
Код:
enum SCams { Float:scX, Float:scY, Float:scZ, scLimit, scObjectID, scDeployedBy[MAX_PLAYER_NAME], scDeployedAt[MAX_ZONE_NAME] }; new SpeedCams[MAX_CAMS][SCams];
Код:
stock SaveCams() { new idx = 1, File:file; new string[256]; while(idx < MAX_CAMS) { format(string, sizeof(string), "%f|%f|%f|%s|%s|%s\r\n", SpeedCams[idx][scX], SpeedCams[idx][scY], SpeedCams[idx][scZ], SpeedCams[idx][scLimit], SpeedCams[idx][scDeployedAt], SpeedCams[idx][scDeployedBy]); if(idx == 1) { file = fopen("speedcams.cfg", io_write); } else { file = fopen("speedcams.cfg", io_append); } fwrite(file, string); fclose(file); idx++; } print("SpeedCams saved successfully."); return 1; }
Код:
stock LoadCams() { new dinfo[15][128]; new string[256]; new File:file = fopen("speedcams.cfg", io_read); if(file) { new idx = 1; new Float: f_TempAngle; while(idx < MAX_CAMS) { fread(file, string); split(string, dinfo, '|'); SpeedCams[idx][scX] = floatstr(dinfo[0]); SpeedCams[idx][scY] = floatstr(dinfo[1]); SpeedCams[idx][scZ] = floatstr(dinfo[2]); SpeedCams[idx][scDeployedAt] = strval(dinfo[3]); SpeedCams[idx][scDeployedBy] = strval(dinfo[4]); SpeedCams[idx][scLimit] = strval(dinfo[5]); if(SpeedCams[idx][scObjectID]) // If speedcam exists { format(string, sizeof(string), "Speedcam ID: %d", idx); SpeedCams[idx][scObjectID] = CreateDynamicObject(18880, SpeedCams[idx][scX], SpeedCams[idx][scY], SpeedCams[idx][scZ]-2.0, 0.0, 0.0, f_TempAngle); //GateInfo[idx][gText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, GateInfo[idx][gCX], GateInfo[idx][gCY], GateInfo[idx][gCZ], 10); } idx++; } } print("SpeedCams loaded successfully."); return 1; }
Deploying Cam:
Код:
CMD:deploycam(playerid, params[]) { if(IsACop(playerid)) { if(PlayerInfo[playerid][pFacRank] >= 5) { for(new idx; idx < sizeof(SpeedCams); idx++) { if(SpeedCams[idx][scX] == 0) { new Float: f_TempAngle, string[128]; GetPlayerPos(playerid, SpeedCams[idx][scX], SpeedCams[idx][scY], SpeedCams[idx][scZ]); GetPlayerFacingAngle(playerid, f_TempAngle); SpeedCams[idx][scObjectID] = CreateDynamicObject(18880, SpeedCams[idx][scX], SpeedCams[idx][scY], SpeedCams[idx][scZ]-2.0, 0.0, 0.0, f_TempAngle); GetPlayer3DZone(playerid, SpeedCams[idx][scDeployedAt], MAX_ZONE_NAME); SpeedCams[idx][scDeployedBy] = RPN(playerid); SpeedCams[idx][scLimit] = 65; format(string,sizeof(string),"Speed Cam ID: %d successfully created [Speed Limit = 50].", idx); SendClientMessage(playerid, COLOR_WHITE, string); format(string, sizeof(string), "HQ: A speeding camera has been deployed by %s at %s.", RPN(playerid), SpeedCams[idx][scDeployedAt]); foreach(Player, x) { if(IsACop(x)) { SendClientMessage(x, TRANSPARENT_BLUE, string); if (PlayerInfo[x][pFacRank] >= 5) { SendClientMessage(x, COLOR_YELLOW, "You can remove a speed camera by typing /destroycam."); } } } return 1; } } SendClientMessage(playerid, COLOR_WHITE, "Unable to spawn more speedcameras, limit is 10." ); } else { SendClientMessage(playerid, COLOR_ORANGE, " You must be rank 3 or higher!"); } } else { SendClientMessage(playerid, COLOR_ORANGE, " You are not a LEO!"); } return 1; }