15.08.2013, 14:47
I downloaded Excel's Position System just before. I tryed to modify it to load and save a players score instead of cordnates. Below is the code, it compiles fine and runs. It saves too, but it will not load an existing file, my score always gets reset to 0 (i know it saved). I assume it is just making a new file.
Modification of Excel's Position System, https://sampforum.blast.hk/showthread.php?tid=421877
I hope an admin doesn't like ban me or something for posting his code lol.
Код:
#include <a_samp> #include <YSI\y_ini> #include <zcmd> #define SavePath "Users/%s/Score.ini" #define COL_WHITE "{FFFFFF}" #define COL_BLACK "{0E0101}" #define COL_GREY "{C3C3C3}" #define COL_GREEN "{6EF83C}" #define COL_RED "{F81414}" #define COL_YELLOW "{F3FF02}" #define COL_ORANGE "{FFAF00}" #define COL_LIME "{B7FF00}" #define COL_CYAN "{00FFEE}" #define COL_BLUE "{0049FF}" #define COL_MAGENTA "{F300FF}" #define COL_VIOLET "{B700FF}" #define COL_PINK "{FF00EA}" #define COL_MARONE "{A90202}" #define DIALOG_LPOS (8399) #define DIALOG_SPOS (8499) /* enum Variables { Float:PosX1, Float:PosY1, Float:PosZ1, Interior1, Float:PosX2, Float:PosY2, Float:PosZ2, Interior2, Float:PosX3, Float:PosY3, Float:PosZ3, Interior3, Float:PosX4, Float:PosY4, Float:PosZ4, Interior4, Float:PosX5, Float:PosY5, Float:PosZ5, Interior5, }*/ //new GScore[MAX_PLAYERS]; //new PositionSaver[MAX_PLAYERS][Variables]; //new Text:StreamPlayerObjects[3]; public OnFilterScriptInit() { print("[FilterScript]Position System ( LOADED ) -By Excel"); /*StreamPlayerObjects[0] = TextDrawCreate(213.000000, 160.000000, "."); TextDrawBackgroundColor(StreamPlayerObjects[0], 255); TextDrawFont(StreamPlayerObjects[0], 1); TextDrawLetterSize(StreamPlayerObjects[0], -0.009999, 6.700000); TextDrawColor(StreamPlayerObjects[0], -1); TextDrawSetOutline(StreamPlayerObjects[0], 0); TextDrawSetProportional(StreamPlayerObjects[0], 1); TextDrawSetShadow(StreamPlayerObjects[0], 1); TextDrawUseBox(StreamPlayerObjects[0], 1); TextDrawBoxColor(StreamPlayerObjects[0], 130); TextDrawTextSize(StreamPlayerObjects[0], 430.000000, 0.000000); StreamPlayerObjects[1] = TextDrawCreate(286.000000, 169.000000, "LOADING..."); TextDrawBackgroundColor(StreamPlayerObjects[1], 255); TextDrawFont(StreamPlayerObjects[1], 2); TextDrawLetterSize(StreamPlayerObjects[1], 0.379999, 1.899999); TextDrawColor(StreamPlayerObjects[1], 16777215); TextDrawSetOutline(StreamPlayerObjects[1], 1); TextDrawSetProportional(StreamPlayerObjects[1], 1); StreamPlayerObjects[2] = TextDrawCreate(323.000000, 198.000000, "Please Wait, Loading Objects From Saved Position."); TextDrawAlignment(StreamPlayerObjects[2], 2); TextDrawBackgroundColor(StreamPlayerObjects[2], 255); TextDrawFont(StreamPlayerObjects[2], 2); TextDrawLetterSize(StreamPlayerObjects[2], 0.169999, 1.099999); TextDrawColor(StreamPlayerObjects[2], -1); TextDrawSetOutline(StreamPlayerObjects[2], 1); TextDrawSetProportional(StreamPlayerObjects[2], 1); return true;*/ return 1; } public OnFilterScriptExit() { return true; } public OnPlayerConnect(playerid) { if(fexist(Path(playerid))) { INI_ParseFile(Path(playerid),"LoadScoreData_%s", .bExtra = true, .extra = playerid); } else { new INI:file = INI_Open(Path(playerid)); INI_SetTag(file,"Player Score"); INI_WriteInt(file, "score", 0); /*INI_WriteFloat(file,"(1)Postion-PosY",0); INI_WriteFloat(file,"(1)Postion-PosZ",0); INI_WriteInt(file,"(1)Interior",0); INI_WriteFloat(file,"(2)Postion-PosX",0); INI_WriteFloat(file,"(2)Postion-PosY",0); INI_WriteFloat(file,"(2)Postion-PosZ",0); INI_WriteInt(file,"(2)Interior",0); INI_WriteFloat(file,"(3)Postion-PosX",0); INI_WriteFloat(file,"(3)Postion-PosY",0); INI_WriteFloat(file,"(3)Postion-PosZ",0); INI_WriteInt(file,"(3)Interior",0); INI_WriteFloat(file,"(4)Postion-PosX",0); INI_WriteFloat(file,"(4)Postion-PosY",0); INI_WriteFloat(file,"(4)Postion-PosZ",0); INI_WriteInt(file,"(4)Interior",0); INI_WriteFloat(file,"(5)Postion-PosX",0); INI_WriteFloat(file,"(5)Postion-PosY",0); INI_WriteFloat(file,"(5)Postion-PosZ",0); INI_WriteInt(file,"(5)Interior",0);*/ INI_Close(file); } return true; } public OnPlayerDisconnect(playerid, reason) { if(fexist(Path(playerid))) { new INI:file = INI_Open(Path(playerid)); INI_SetTag(file,"Player Score"); INI_WriteInt(file, "score", GetPlayerScore(playerid)); /*INI_WriteFloat(file,"(1)Postion-PosY",PositionSaver[playerid][PosY1]); INI_WriteFloat(file,"(1)Postion-PosZ",PositionSaver[playerid][PosZ1]); INI_WriteInt(file,"(1)Interior",PositionSaver[playerid][Interior1]); INI_WriteFloat(file,"(2)Postion-PosX",PositionSaver[playerid][PosX2]); INI_WriteFloat(file,"(2)Postion-PosY",PositionSaver[playerid][PosY2]); INI_WriteFloat(file,"(2)Postion-PosZ",PositionSaver[playerid][PosZ2]); INI_WriteInt(file,"(2)Interior",PositionSaver[playerid][Interior2]); INI_WriteFloat(file,"(3)Postion-PosX",PositionSaver[playerid][PosX3]); INI_WriteFloat(file,"(3)Postion-PosY",PositionSaver[playerid][PosY3]); INI_WriteFloat(file,"(3)Postion-PosZ",PositionSaver[playerid][PosZ3]); INI_WriteInt(file,"(3)Interior",PositionSaver[playerid][Interior3]); INI_WriteFloat(file,"(4)Postion-PosX",PositionSaver[playerid][PosX4]); INI_WriteFloat(file,"(4)Postion-PosY",PositionSaver[playerid][PosY4]); INI_WriteFloat(file,"(4)Postion-PosZ",PositionSaver[playerid][PosZ4]); INI_WriteInt(file,"(4)Interior",PositionSaver[playerid][Interior4]); INI_WriteFloat(file,"(5)Postion-PosX",PositionSaver[playerid][PosX5]); INI_WriteFloat(file,"(5)Postion-PosY",PositionSaver[playerid][PosY5]); INI_WriteFloat(file,"(5)Postion-PosZ",PositionSaver[playerid][PosZ5]); INI_WriteInt(file,"(5)Interior",PositionSaver[playerid][Interior5]);*/ INI_Close(file); } return true; } stock Path(playerid) { new str[128], name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,sizeof(name)); format(str,sizeof(str), SavePath,name); return str; } forward LoadScoreData_user(playerid, name[], value[]); public LoadScoreData_user(playerid, name[], value[]) { new GScore[MAX_PLAYERS]; INI_Int("score", GScore[playerid]); SetPlayerScore(playerid, GScore[5]); /* INI_Float("(1)Postion-PosY",PositionSaver[playerid][PosY1]); INI_Float("(1)Postion-PosZ",PositionSaver[playerid][PosZ1]); INI_Int("(1)Interior",PositionSaver[playerid][Interior1]); INI_Float("(2)Postion-PosX",PositionSaver[playerid][PosX2]); INI_Float("(2)Postion-PosY",PositionSaver[playerid][PosY2]); INI_Float("(2)Postion-PosZ",PositionSaver[playerid][PosZ2]); INI_Int("(2)Interior",PositionSaver[playerid][Interior2]); INI_Float("(3)Postion-PosX",PositionSaver[playerid][PosX3]); INI_Float("(3)Postion-PosY",PositionSaver[playerid][PosY3]); INI_Float("(3)Postion-PosZ",PositionSaver[playerid][PosZ3]); INI_Int("(3)Interior",PositionSaver[playerid][Interior3]); INI_Float("(4)Postion-PosX",PositionSaver[playerid][PosX4]); INI_Float("(4)Postion-PosY",PositionSaver[playerid][PosY4]); INI_Float("(4)Postion-PosZ",PositionSaver[playerid][PosZ4]); INI_Int("(4)Interior",PositionSaver[playerid][Interior4]); INI_Float("(5)Postion-PosX",PositionSaver[playerid][PosX5]); INI_Float("(5)Postion-PosY",PositionSaver[playerid][PosY5]); INI_Float("(5)Postion-PosZ",PositionSaver[playerid][PosZ5]); INI_Int("(5)Interior",PositionSaver[playerid][Interior5]);*/ return true; } /* forward StartLoading(playerid); public StartLoading(playerid) { TogglePlayerControllable(playerid, false); TextDrawShowForPlayer(playerid, StreamPlayerObjects[0]); TextDrawShowForPlayer(playerid, StreamPlayerObjects[1]); TextDrawShowForPlayer(playerid, StreamPlayerObjects[2]); SetTimerEx("StopLoading", 3500, false, "i", playerid); return true; } forward StopLoading(playerid); public StopLoading(playerid) { TogglePlayerControllable(playerid, true); TextDrawHideForPlayer(playerid, StreamPlayerObjects[0]); TextDrawHideForPlayer(playerid, StreamPlayerObjects[1]); TextDrawHideForPlayer(playerid, StreamPlayerObjects[2]); return true; } */ /* COMMAND:lpos(playerid, params[]) { return ShowPlayerDialog(playerid, DIALOG_LPOS, DIALOG_STYLE_LIST, ""COL_CYAN"Please Select A Position To "COL_WHITE"LOAD:", "1\n\ 2\n\ 3\n\ 4\n\ 5", "Select", "Cancel"); } COMMAND:spos(playerid, params[]) { return ShowPlayerDialog(playerid, DIALOG_SPOS, DIALOG_STYLE_LIST, ""COL_CYAN"Please Select A Position To "COL_WHITE"SAVE:", "1\n\ 2\n\ 3\n\ 4\n\ 5", "Select", "Cancel"); } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch(dialogid) { case DIALOG_LPOS: { if(response) { switch(listitem) { case 0: { if(PositionSaver[playerid][PosX1] != 0 || PositionSaver[playerid][PosY1] != 0 || PositionSaver[playerid][PosZ1] != 0) { StartLoading(playerid); SetPlayerInterior(playerid, PositionSaver[playerid][Interior1]); SetPlayerPos(playerid, PositionSaver[playerid][PosX1], PositionSaver[playerid][PosY1], PositionSaver[playerid][PosZ1]); } else GameTextForPlayer(playerid, "~r~No Position Saved In Slot ~w~( 1 )", 3000, 3), ShowPlayerDialog(playerid, DIALOG_LPOS, DIALOG_STYLE_LIST, ""COL_CYAN"Please Select A Position To "COL_WHITE"LOAD:", "1\n\ 2\n\ 3\n\ 4\n\ 5", "Select", "Cancel"); } case 1: { if(PositionSaver[playerid][PosX2] != 0 || PositionSaver[playerid][PosY2] != 0 || PositionSaver[playerid][PosZ2] != 0) { StartLoading(playerid); SetPlayerInterior(playerid, PositionSaver[playerid][Interior2]); SetPlayerPos(playerid, PositionSaver[playerid][PosX2], PositionSaver[playerid][PosY2], PositionSaver[playerid][PosZ2]); } else GameTextForPlayer(playerid, "~r~No Position Saved In Slot ~w~( 2 )", 3000, 3), ShowPlayerDialog(playerid, DIALOG_LPOS, DIALOG_STYLE_LIST, ""COL_CYAN"Please Select A Position To "COL_WHITE"LOAD:", "1\n\ 2\n\ 3\n\ 4\n\ 5", "Select", "Cancel"); } case 2: { if(PositionSaver[playerid][PosX3] != 0 || PositionSaver[playerid][PosY3] != 0 || PositionSaver[playerid][PosZ3] != 0) { StartLoading(playerid); SetPlayerInterior(playerid, PositionSaver[playerid][Interior3]); SetPlayerPos(playerid, PositionSaver[playerid][PosX3], PositionSaver[playerid][PosY3], PositionSaver[playerid][PosZ3]); } else GameTextForPlayer(playerid, "~r~No Position Saved In Slot ~w~( 3 )", 3000, 3), ShowPlayerDialog(playerid, DIALOG_LPOS, DIALOG_STYLE_LIST, ""COL_CYAN"Please Select A Position To "COL_WHITE"LOAD:", "1\n\ 2\n\ 3\n\ 4\n\ 5", "Select", "Cancel"); } case 3: { if(PositionSaver[playerid][PosX4] != 0 || PositionSaver[playerid][PosY4] != 0 || PositionSaver[playerid][PosZ4] != 0) { StartLoading(playerid); SetPlayerInterior(playerid, PositionSaver[playerid][Interior4]); SetPlayerPos(playerid, PositionSaver[playerid][PosX4], PositionSaver[playerid][PosY4], PositionSaver[playerid][PosZ4]); } else GameTextForPlayer(playerid, "~r~No Position Saved In Slot ~w~( 4 )", 3000, 3), ShowPlayerDialog(playerid, DIALOG_LPOS, DIALOG_STYLE_LIST, ""COL_CYAN"Please Select A Position To "COL_WHITE"LOAD:", "1\n\ 2\n\ 3\n\ 4\n\ 5", "Select", "Cancel"); } case 4: { if(PositionSaver[playerid][PosX5] != 0 || PositionSaver[playerid][PosY5] != 0 || PositionSaver[playerid][PosZ5] != 0) { StartLoading(playerid); SetPlayerInterior(playerid, PositionSaver[playerid][Interior5]); SetPlayerPos(playerid, PositionSaver[playerid][PosX1], PositionSaver[playerid][PosY1], PositionSaver[playerid][PosZ1]); } else GameTextForPlayer(playerid, "~r~No Position Saved In Slot ~w~( 5 )", 3000, 3), ShowPlayerDialog(playerid, DIALOG_LPOS, DIALOG_STYLE_LIST, ""COL_CYAN"Please Select A Position To "COL_WHITE"LOAD:", "1\n\ 2\n\ 3\n\ 4\n\ 5", "Select", "Cancel"); } } } } } switch(dialogid) { case DIALOG_SPOS: { if(response) { switch(listitem) { case 0: { if(PositionSaver[playerid][PosX1] != 0 || PositionSaver[playerid][PosY1] != 0 || PositionSaver[playerid][PosZ1] != 0) { return ShowPlayerDialog(playerid, 440, DIALOG_STYLE_MSGBOX, ""COL_CYAN"WARNING:", ""COL_WHITE"Do you want to overwrite the saved position at earliar ?", "Yes", "No"); } new Float:posx, Float:posy, Float:posz; PositionSaver[playerid][Interior1]=GetPlayerInterior(playerid); GetPlayerPos(playerid, posx, posy, posz); PositionSaver[playerid][PosX1]=posx; PositionSaver[playerid][PosY1]=posy; PositionSaver[playerid][PosZ1]=posz; GameTextForPlayer(playerid, "~g~POSITION SAVED ~w~Slot ( 1 )", 3000, 3); } case 1: { if(PositionSaver[playerid][PosX2] != 0 || PositionSaver[playerid][PosY2] != 0 || PositionSaver[playerid][PosZ2] != 0) { return ShowPlayerDialog(playerid, 441, DIALOG_STYLE_MSGBOX, ""COL_CYAN"WARNING:", ""COL_WHITE"Do you want to overwrite the saved position at earliar ?", "Yes", "No"); } new Float:posx, Float:posy, Float:posz; PositionSaver[playerid][Interior2]=GetPlayerInterior(playerid); GetPlayerPos(playerid, posx, posy, posz); PositionSaver[playerid][PosX2]=posx; PositionSaver[playerid][PosY2]=posy; PositionSaver[playerid][PosZ2]=posz; GameTextForPlayer(playerid, "~g~POSITION SAVED ~w~Slot ( 2 )", 3000, 3); } case 2: { if(PositionSaver[playerid][PosX3] != 0 || PositionSaver[playerid][PosY3] != 0 || PositionSaver[playerid][PosZ3] != 0) { return ShowPlayerDialog(playerid, 442, DIALOG_STYLE_MSGBOX, ""COL_CYAN"WARNING:", ""COL_WHITE"Do you want to overwrite the saved position at earliar ?", "Yes", "No"); } new Float:posx, Float:posy, Float:posz; PositionSaver[playerid][Interior3]=GetPlayerInterior(playerid); GetPlayerPos(playerid, posx, posy, posz); PositionSaver[playerid][PosX3]=posx; PositionSaver[playerid][PosY3]=posy; PositionSaver[playerid][PosZ3]=posz; GameTextForPlayer(playerid, "~g~POSITION SAVED ~w~Slot ( 3 )", 3000, 3); } case 3: { if(PositionSaver[playerid][PosX4] != 0 || PositionSaver[playerid][PosY4] != 0 || PositionSaver[playerid][PosZ4] != 0) { return ShowPlayerDialog(playerid, 443, DIALOG_STYLE_MSGBOX, ""COL_CYAN"WARNING:", ""COL_WHITE"Do you want to overwrite the saved position at earliar ?", "Yes", "No"); } new Float:posx, Float:posy, Float:posz; PositionSaver[playerid][Interior4]=GetPlayerInterior(playerid); GetPlayerPos(playerid, posx, posy, posz); PositionSaver[playerid][PosX4]=posx; PositionSaver[playerid][PosY4]=posy; PositionSaver[playerid][PosZ4]=posz; GameTextForPlayer(playerid, "~g~POSITION SAVED ~w~Slot ( 4 )", 3000, 3); } case 4: { if(PositionSaver[playerid][PosX5] != 0 || PositionSaver[playerid][PosY5] != 0 || PositionSaver[playerid][PosZ5] != 0) { return ShowPlayerDialog(playerid, 444, DIALOG_STYLE_MSGBOX, ""COL_CYAN"WARNING:", ""COL_WHITE"Do you want to overwrite the saved position at earliar ?", "Yes", "No"); } new Float:posx, Float:posy, Float:posz; PositionSaver[playerid][Interior5]=GetPlayerInterior(playerid); GetPlayerPos(playerid, posx, posy, posz); PositionSaver[playerid][PosX5]=posx; PositionSaver[playerid][PosY5]=posy; PositionSaver[playerid][PosZ5]=posz; GameTextForPlayer(playerid, "~g~POSITION SAVED ~w~Slot ( 5 )", 3000, 3); } } } } } switch(dialogid) { case 440: { if(!response) { ShowPlayerDialog(playerid, DIALOG_SPOS, DIALOG_STYLE_LIST, ""COL_CYAN"Please Select A Position To "COL_WHITE"SAVE:", "1\n\ 2\n\ 3\n\ 4\n\ 5", "Select", "Cancel"); } if(response) { new Float:posx, Float:posy, Float:posz; PositionSaver[playerid][Interior1]=GetPlayerInterior(playerid); GetPlayerPos(playerid, posx, posy, posz); PositionSaver[playerid][PosX1]=posx; PositionSaver[playerid][PosY1]=posy; PositionSaver[playerid][PosZ1]=posz; GameTextForPlayer(playerid, "~g~POSITION OVERWRITED ~w~Slot ( 1 )", 3000, 3); } } case 441: { if(!response) { ShowPlayerDialog(playerid, DIALOG_SPOS, DIALOG_STYLE_LIST, ""COL_CYAN"Please Select A Position To "COL_WHITE"SAVE:", "1\n\ 2\n\ 3\n\ 4\n\ 5", "Select", "Cancel"); } if(response) { new Float:posx, Float:posy, Float:posz; PositionSaver[playerid][Interior2]=GetPlayerInterior(playerid); GetPlayerPos(playerid, posx, posy, posz); PositionSaver[playerid][PosX2]=posx; PositionSaver[playerid][PosY2]=posy; PositionSaver[playerid][PosZ2]=posz; GameTextForPlayer(playerid, "~g~POSITION OVERWRITED ~w~Slot ( 2 )", 3000, 3); } } case 442: { if(!response) { ShowPlayerDialog(playerid, DIALOG_SPOS, DIALOG_STYLE_LIST, ""COL_CYAN"Please Select A Position To "COL_WHITE"SAVE:", "1\n\ 2\n\ 3\n\ 4\n\ 5", "Select", "Cancel"); } if(response) { new Float:posx, Float:posy, Float:posz; PositionSaver[playerid][Interior3]=GetPlayerInterior(playerid); GetPlayerPos(playerid, posx, posy, posz); PositionSaver[playerid][PosX3]=posx; PositionSaver[playerid][PosY3]=posy; PositionSaver[playerid][PosZ3]=posz; GameTextForPlayer(playerid, "~g~POSITION OVERWRITED ~w~Slot ( 3 )", 3000, 3); } } case 443: { if(!response) { ShowPlayerDialog(playerid, DIALOG_SPOS, DIALOG_STYLE_LIST, ""COL_CYAN"Please Select A Position To "COL_WHITE"SAVE:", "1\n\ 2\n\ 3\n\ 4\n\ 5", "Select", "Cancel"); } if(response) { new Float:posx, Float:posy, Float:posz; PositionSaver[playerid][Interior4]=GetPlayerInterior(playerid); GetPlayerPos(playerid, posx, posy, posz); PositionSaver[playerid][PosX4]=posx; PositionSaver[playerid][PosY4]=posy; PositionSaver[playerid][PosZ4]=posz; GameTextForPlayer(playerid, "~g~POSITION OVERWRITED ~w~Slot ( 4 )", 3000, 3); } } case 444: { if(!response) { ShowPlayerDialog(playerid, DIALOG_SPOS, DIALOG_STYLE_LIST, ""COL_CYAN"Please Select A Position To "COL_WHITE"SAVE:", "1\n\ 2\n\ 3\n\ 4\n\ 5", "Select", "Cancel"); } if(response) { new Float:posx, Float:posy, Float:posz; PositionSaver[playerid][Interior5]=GetPlayerInterior(playerid); GetPlayerPos(playerid, posx, posy, posz); PositionSaver[playerid][PosX5]=posx; PositionSaver[playerid][PosY5]=posy; PositionSaver[playerid][PosZ5]=posz; GameTextForPlayer(playerid, "~g~POSITION OVERWRITED ~w~Slot ( 5 )", 3000, 3); } } } return true; } */
I hope an admin doesn't like ban me or something for posting his code lol.