25.05.2010, 09:22
Quote:
#include <a_samp> #include <zcmdsscanf> #include <dini> #define file_path "%s.ini" //This line defines the place that the player file is stored. change to "Foldername/subfoldername/%s.ini" if you want it another place. new file[128]; //This stores the file_path, so it can use it later on. format(file, sizeof(file), file_path, playername); //Tells that inside file is file_path. and the playername is because there should be a %s in the file_path. public OnPlayerSpawn(playerid) // When the player has picked a skin after his crash, then it sets him to what he was last time. { if(dini_Exists(file)) { SetPlayerPos(playerid, dini_Int(file, "PosX"), dini_Int(file, "PosY"), dini_Int(file, "PosZ")); SetPlayerFacingAngle(playerid, dini_Int(file, "PosA")); SetPlayerHealth(playerid, dini_Int(file, "HP")); SetPlayerArmour(playerid, dini_Int(file, "AP")); SetPlayerInterior(playerid, dini_Int(file, "Interior")); SetPlayerWorld(playerid, dini_Int(file, "World")); SetPlayerScore(playerid, dini_Int(file, "Score")); SetPlayerColor(playerid, dini_Get(file, "Color")); SetPlayerSkin(playerid, dini_Int(file, "Skin")); GivePlayerWeapon(playerid, dini_Int(file, "Weapon1"), dini_Int(file, "Weapon1Ammo")); GivePlayerWeapon(playerid, dini_Int(file, "Weapon2"), dini_Int(file, "Weapon2Ammo")); GivePlayerWeapon(playerid, dini_Int(file, "Weapon3"), dini_Int(file, "Weapon3Ammo")); GivePlayerWeapon(playerid, dini_Int(file, "Weapon4"), dini_Int(file, "Weapon4Ammo")); GivePlayerWeapon(playerid, dini_Int(file, "Weapon5"), dini_Int(file, "Weapon5Ammo")); } return 1; } public OnPlayerDisconnect(playerid) // when the player disconnects then we get the server to check if its a crash, if it is. then it creats a file, if its not then it deletes his file if there is any. { new name[MAX_PLAYER_NAME], string[44]; GetPlayerName(playerid, name, sizeof(name)); switch(reason) { case 0: PlayerCrashed(playerid); format(string, sizeof(string), "%s has left the server. (Crashed)", pname); case 1: PlayerLeft(playerid); case 2: PlayerLeft(playerid); } SendClientMessageToAll(0xAAAAAAAA, string); //sends the string which says "%s has left the server. (Crashed) return 1; } public OnPlayerConnect(playerid) // When the player connects, and a file with his name exists. which means that he disconnected. then it tells him that we have saved his stats { if(dini_Exists(file)) { SendClientMessage(playerid, 0xFFFFFFFF, "Welcome back from your crash, we have saved your stats"); } return 1; } PlayerCrashed(playerid) // This function saves the players weapons into a variable. Saves the players stats into the file. { new Float, Float:y, Float:z, Float:a, Weapon[13][2]; GetPlayerPos(playerid,x,y,z) for(new = i; i < 13; i++) { GetPlayerWeaponData(playerid, i, Weapon * , Weapon[1]); } if(!dini_Exists(file)) { dini_Create(file); dini_IntSet(file, "PosX", x); dini_IntSet(file, "PosY", y); dini_IntSet(file, "PosZ", z); dini_IntSet(file, "PosA", a); dini_IntSet(file, "HP", GetPlayerHealth(playerid)); dini_IntSet(file, "AP", GetPlayerArmour(playerid)); dini_IntSet(file, "Interior", GetPlayerInterior(playerid)); dini_IntSet(file, "World", GetPlayerVirtualWorld(playerid)); dini_IntSet(file, "Score", GetPlayerScore(playerid)); dini_Set(file, "Color", GetPlayerColor(playerid)); dini_IntSet(file, "Skin", GetPlayerSkin(playerid)); dini_IntSet(file, "Weapon1", Weapon[1][0]); dini_IntSet(file, "Weapon1Ammo", Weapon[1][1]); dini_IntSet(file, "Weapon2", Weapon[2][0]); dini_IntSet(file, "Weapon2Ammo", Weapon[2][1]); dini_IntSet(file, "Weapon3", Weapon[3][0]); dini_IntSet(file, "Weapon3Ammo", Weapon[3][1]); dini_IntSet(file, "Weapon4", Weapon[4][0]); dini_IntSet(file, "Weapon4Ammo", Weapon[4][1]); dini_IntSet(file, "Weapon5", Weapon[5][0]); dini_IntSet(file, "Weapon5Ammo", Weapon[5][1]); } return 1; } PlayerLeft(playerid) // If the player left insted of disconnecting, which means if he gets kicked or does /q then it deletes his player file if there is any. { if(dini_Exists(file)) { dini_Remove(file); } return 1; } |
Quote:
C:\Users\kllerlakken\Desktop\LoRP\filterscripts\Lo RP Crash Script.pwn(11) : error 021: symbol already defined: "format" C:\Users\kllerlakken\Desktop\LoRP\filterscripts\Lo RP Crash Script.pwn(22) : error 017: undefined symbol "SetPlayerWorld" C:\Users\kllerlakken\Desktop\LoRP\filterscripts\Lo RP Crash Script.pwn(24) : error 035: argument type mismatch (argument 2) C:\Users\kllerlakken\Desktop\LoRP\filterscripts\Lo RP Crash Script.pwn(40) : error 017: undefined symbol "reason" C:\Users\kllerlakken\Desktop\LoRP\filterscripts\Lo RP Crash Script.pwn(42) : error 002: only a single statement (or expression) can follow each "case" C:\Users\kllerlakken\Desktop\LoRP\filterscripts\Lo RP Crash Script.pwn(42) : error 017: undefined symbol "pname" C:\Users\kllerlakken\Desktop\LoRP\filterscripts\Lo RP Crash Script.pwn(42) : warning 215: expression has no effect C:\Users\kllerlakken\Desktop\LoRP\filterscripts\Lo RP Crash Script.pwn(43) : error 014: invalid statement; not in switch C:\Users\kllerlakken\Desktop\LoRP\filterscripts\Lo RP Crash Script.pwn(43) : warning 215: expression has no effect C:\Users\kllerlakken\Desktop\LoRP\filterscripts\Lo RP Crash Script.pwn(43) : error 001: expected token: ";", but found ":" C:\Users\kllerlakken\Desktop\LoRP\filterscripts\Lo RP Crash Script.pwn(43) : error 029: invalid expression, assumed zero C:\Users\kllerlakken\Desktop\LoRP\filterscripts\Lo RP Crash Script.pwn(43) : fatal error 107: too many error messages on one line |