Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Save Spawn Pos by AiRaLoKa
- // Credits
- // - AiRaLoKa : For making this whole filterscript
- // - Zeex : For zcmd
- // - Y_Less : For y_ini
- #define FILTERSCRIPT
- #include <a_samp>
- #include <zcmd>
- #include <YSI\y_ini>
- #define PATH "/Users/%s.ini"
- #define ROSU 0x00CC00FF
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Save Spawn Pos by AiRaLoKa");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main(){}
- #endif
- enum pInfo
- {
- pUsePos,
- Float:pA,
- Float:pX,
- Float:pY,
- Float:pZ,
- pHasSavedPos
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- forward LoadUser_PlayerData(playerid,name[],value[]);
- public LoadUser_PlayerData(playerid,name[],value[])
- {
- INI_Int("UseSpawnPos",PlayerInfo[playerid][pUsePos]);
- INI_Float("FloatA",PlayerInfo[playerid][pA]);
- INI_Float("FloatX",PlayerInfo[playerid][pX]);
- INI_Float("FloatY",PlayerInfo[playerid][pY]);
- INI_Float("FloatZ",PlayerInfo[playerid][pZ]);
- INI_Int("HasSavedPos",PlayerInfo[playerid][pHasSavedPos]);
- return 1;
- }
- CMD:savespawnpos(playerid,params[])
- {
- new Float:posA,Float:posX,Float:posY,Float:posZ;
- GetPlayerPos(playerid,posX,posY,posZ);
- GetPlayerFacingAngle(playerid,posA);
- PlayerInfo[playerid][pA]=posA;
- PlayerInfo[playerid][pX]=posX;
- PlayerInfo[playerid][pY]=posY;
- PlayerInfo[playerid][pZ]=posZ;
- PlayerInfo[playerid][pHasSavedPos]=1;
- SendClientMessage(playerid, ROSU, "[INFO]: Spawn position saved!");
- return 1;
- }
- CMD:usesavedspawnpos(playerid, params[])
- {
- if(!strcmp(params,"on"))
- {
- if(PlayerInfo[playerid][pHasSavedPos]==1)
- {
- PlayerInfo[playerid][pUsePos]=1;
- SendClientMessage(playerid, ROSU, "[INFO]: You will be spawned on your saved spawn position");
- }
- else if(PlayerInfo[playerid][pHasSavedPos]==0)
- {
- SendClientMessage(playerid, 0xFF0000FF, "[ERROR]: You don't have any saved spawn position");
- }
- }
- else if(!strcmp(params,"off"))
- {
- PlayerInfo[playerid][pUsePos]=0;
- SendClientMessage(playerid, ROSU, "[INFO]: You will not spawned on your saved spawn position anymore");
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File, "PlayerData");
- INI_WriteInt(File,"UseSpawnPos",PlayerInfo[playerid][pUsePos]);
- INI_WriteFloat(File,"FloatA",PlayerInfo[playerid][pA]);
- INI_WriteFloat(File,"FloatX",PlayerInfo[playerid][pX]);
- INI_WriteFloat(File,"FloatY",PlayerInfo[playerid][pY]);
- INI_WriteFloat(File,"FloatZ",PlayerInfo[playerid][pZ]);
- INI_WriteInt(File,"HasSavedPos",PlayerInfo[playerid][pHasSavedPos]);
- INI_Close(File);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(PlayerInfo[playerid][pUsePos]==1)
- {
- SetPlayerPos(playerid, PlayerInfo[playerid][pX], PlayerInfo[playerid][pY], PlayerInfo[playerid][pZ]);
- SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pA]);
- }
- return 1;
- }
- stock UserPath(playerid)
- {
- new string[128],playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid,playername,sizeof(playername));
- format(string,sizeof(string),PATH,playername);
- return string;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement