27.07.2016, 13:55
Hi,
currently the spawn system I currently have in place, seems to work except 1 flaw. It appears that whenever a new player joins and registers an account on the server, Player ID 0 teleports to the default starting pos for players. This only seems to happen for new accounts, with existing accounts, not having any affect. any help would be appreciated.
currently the spawn system I currently have in place, seems to work except 1 flaw. It appears that whenever a new player joins and registers an account on the server, Player ID 0 teleports to the default starting pos for players. This only seems to happen for new accounts, with existing accounts, not having any affect. any help would be appreciated.
Код:
public OnPlayerConnect(playerid) { TogglePlayerSpectating(playerid, true); if(fexist(UserPath(playerid))) //If the User account exists { INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); //Loads the data from the user's textfile (password) ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Authentication","{FFFFFF}Welcome to {FF0000}Vexed Roleplay\n{FFFFFF}Please type your password to login.","Login","Quit");//Shows the login Dialog } else //If the user account doesn't exist { ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Authentication","{FFFFFF}Welcome to {FF0000}Vexed Roleplay\n{FFFFFF}Please type your password to register.","Register","Quit");//Show the register Dialog } SetPlayerColor(playerid,COLOR_PLAYER);//Set the players color SendConnectionMessage(playerid, 1);//Send connection message. //---------------Speedo----------------------// stimer[playerid] = SetTimerEx("Speedometer", 100, true, "i", playerid); Speedo = CreatePlayerTextDraw(playerid, 530.0, 340.5," "); PlayerTextDrawShow(playerid,Speedo); // --- Zone-----------------------------// for(new i=0; i<MAX_PLAYERS; i++){ TextDrawHideForPlayer(i, Zones[i]);} //----Total Time in server PlayerInfo[playerid][ConnectTime] = gettime(); return 1; }
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch( dialogid ) { case DIALOG_REGISTER: { if (!response) { new msg[128]; format(msg,sizeof(msg),"%s has been kicked by the server (Failed To Register)", GetName(playerid)); SendClientMessageToAll(COLOR_GREEN,msg); Kick(playerid); } if(response) //If he clicks the first button { if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit"); //This happens if the user has input no password. You can add limits here. new buf[129]; //Now we'll use our Whirlpool hashing new INI:File = INI_Open(UserPath(playerid)); //Opening the user file INI_SetTag(File,"data"); //Settings tags WP_Hash(buf, sizeof(buf), inputtext); //Hashing the inputtext (password) INI_WriteString(File,"Password", buf); //Writes a string, the password, hashed INI_WriteInt(File, "Cash",0); INI_WriteInt(File, "Admin", 0); INI_WriteFloat(File, "PosX", 0); INI_WriteFloat(File, "PosY", 0); INI_WriteFloat(File, "PosZ", 0); INI_WriteFloat(File, "PosA", 0); INI_WriteInt(File, "ChosenSkin", 0); INI_WriteInt(File, "Skin",1); INI_WriteInt(File, "UCAdmin", 0); INI_WriteInt(File, "DriversLicense",0); INI_WriteInt(File, "Hours",0); INI_WriteInt(File, "Minutes",0); INI_WriteInt(File, "Seconds", 0); INI_WriteInt(File, "pInJail",0); INI_WriteInt(File, "pInJailTime",0); INI_WriteInt(File, "Banned",0); INI_Close(File); pNewlyRegged[playerid] = true; //Changing the value of our boolean GivePlayerCash(playerid, 15000); //Gives a $15,000 ammount of starting cash SaveAccountStats(playerid); //Saves the player's account stats TogglePlayerSpectating(playerid, false); SetTimer("SpectateFix", 350, false); //Fixes a bug that needs this timer in order to successfully use mSelection SendPlayerFormattedText(playerid, COLOR_YELLOW,"Account '%s' created. You have been logged in automatically!", GetName(playerid), ""); SendAllFormattedText(COLOR_GREEN, "%s has registered a new account. Welcome to our server!", GetName(playerid), ""); } } case DIALOG_LOGIN: { if (!response) { new msg[128]; format(msg,sizeof(msg),"%s has been kicked by the server (Failed To Login)", GetName(playerid)); SendClientMessageToAll(COLOR_GREEN,msg); Kick(playerid); } if( response ) { new hashpass[129]; WP_Hash(hashpass,sizeof(hashpass),inputtext); if(!strcmp(hashpass, PlayerInfo[playerid][pPass], false)) //Compares the inputtext to the player's pass, pPass. { TogglePlayerSpectating(playerid, false); pNewlyRegged[playerid] = false; SetPlayerCash(playerid, PlayerInfo[playerid][pCash]); //Gives the player the cash he has SetSpawnInfo(playerid, 0 /*Because the player has no team*/, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pXPos], PlayerInfo[playerid][pYPos], PlayerInfo[playerid][pZPos], PlayerInfo[playerid][pAPos], -1, -1, -1, -1, -1, -1); //Sets the player's spawn information SendClientMessage(playerid, -1, "* You have successfully logged in."); LoggedIn[playerid]=1; if(PlayerInfo[playerid][pBanned] == 1) { Ban(playerid); } if(PlayerInfo[playerid][pAdmin] != 0) { new msgID[128], msg[128]; if(PlayerInfo[playerid][pUCAdmin] == 0) { format(msgID, 32, "Administration Level - %d", PlayerInfo[playerid][pAdmin]); SendClientMessage(playerid, COLOR_ADMIN, msgID); if(PlayerInfo[playerid][pAdmin] >= 6) { format(msg,sizeof(msg), "* %s (ID%d) has logged in as Administrator Level 5.", GetName(playerid), playerid); } else { format(msg, sizeof(msg), "* %s (ID%d) has logged in as Administrator Level %d.", GetName(playerid), playerid, PlayerInfo[playerid][pAdmin]); } for(new i = 0; i < MAX_PLAYERS; i++) { if(!IsPlayerConnected(i)) continue; if(PlayerInfo[i][pAdmin] != 0 && i != playerid && LoggedIn[playerid]==1) ABroadCast(COLOR_ADMIN, msg, 1); } } else { format(msgID, 64, "Administration Level - %d (Undercover)", PlayerInfo[playerid][pAdmin]); SendClientMessage(playerid, COLOR_ADMIN, msgID); } } } else { ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit"); //If the player has entered an invalid password, he's prompted to retype his password } return false; } } } return 1; }
Код:
public OnPlayerSpawn(playerid) { SetPlayerInterior(playerid,0); SetPlayerColor(playerid,COLOR_PLAYER); TextDrawShowForPlayer(playerid,txtTimeDisp); TextDrawShowForPlayer(playerid, urlText); TextDrawShowForPlayer(playerid, JoinText); if(PlayerInfo[playerid][pSkin] == 0) { ShowModelSelectionMenu(playerid, skinlist, "Skin Selection"); //Shows the skin selection menu for the player SetPlayerPos(playerid,-1969.3101,137.8635,27.6875); SetPlayerFacingAngle(playerid,88.8534); LoggedIn[playerid] = 1; //Changes the value of our variable "Logged" to 1("true"). } else //If the player logged in { SetPlayerPos(playerid, PlayerInfo[playerid][pXPos], PlayerInfo[playerid][pYPos], PlayerInfo[playerid][pZPos]); SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pAPos]); //Sets the player position to his last position SetPlayerSkin(playerid,PlayerInfo[playerid][pSkin]); } for(new i=0; i<MAX_PLAYERS; i++){TextDrawShowForPlayer(i, Zones[i]);} return 1; }
Код:
public OnPlayerModelSelection(playerid, response, listid, modelid) { if(listid == skinlist) { if(response) { new string[129]; format(string, sizeof(string), "{3685BA}SERVER: {FFFFFF}You have set your skin to ID %d!", modelid); SendClientMessage(playerid, -1, string); SetPlayerSkin(playerid, modelid); new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"data"); INI_WriteInt(File,"Skin",modelid); INI_WriteInt(File,"ChosenSkin", 1); INI_Close(File); PlayerInfo[playerid][pSkin]= GetPlayerSkin(playerid); } else { SendClientMessage(playerid, -1, "{3685BA}SERVER: {FFFFFF}You must select a skin."); ShowModelSelectionMenu(playerid, skinlist, "Skin Selection"); return 1; } } return 1; }
Код:
//=============== Account Saving ================// enum pInfo { pPass[129], pCash, pAdmin, Float:pXPos, Float:pYPos, Float:pZPos, Float:pAPos, pSkin, pUCAdmin, TotalTime, ConnectTime, hours, minutes, seconds, pDriverLicense, pInJail, pInJailTime, pBanned, pBannedBy[30], pReason[128], BannedIP[22] } new PlayerInfo[MAX_PLAYERS][pInfo]; public SaveAccountStats(playerid) { if(LoggedIn[playerid] == 1) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"data"); //Settings tags in y_ini is very important! PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid); PlayerInfo[playerid][pCash] = GetPlayerCash(playerid); new Float:x, Float:y, Float:z; GetPlayerPos(playerid,x,y,z); PlayerInfo[playerid][pXPos] = x; PlayerInfo[playerid][pYPos] = y; PlayerInfo[playerid][pZPos] = z; PlayerInfo [playerid] [pSkin] = GetPlayerSkin(playerid); new h, m, s; TotalGameTime(playerid, h, m, s); INI_WriteInt(File, "Cash", GetPlayerMoney(playerid)); INI_WriteInt(File, "Admin", PlayerInfo[playerid][pAdmin]); INI_WriteFloat(File, "PosX", PlayerInfo[playerid][pXPos]); INI_WriteFloat(File, "PosY", PlayerInfo[playerid][pYPos]); INI_WriteFloat(File, "PosZ", PlayerInfo[playerid][pZPos]); INI_WriteFloat(File, "PosA", PlayerInfo[playerid][pAPos]); INI_WriteInt(File, "Skin",PlayerInfo[playerid][pSkin]); INI_WriteInt(File, "UCAdmin", PlayerInfo[playerid][pUCAdmin]); INI_WriteInt(File, "DriversLicense", PlayerInfo[playerid][pDriverLicense]); INI_WriteInt(File, "Hours", PlayerInfo[playerid][hours] + h); INI_WriteInt(File, "Minutes", PlayerInfo[playerid][minutes]+ m); INI_WriteInt(File, "Seconds", PlayerInfo[playerid][seconds] + s); INI_WriteInt(File, "pInJail", PlayerInfo[playerid][pInJail]); INI_WriteInt(File, "pInJailTime", PlayerInfo[playerid][pInJailTime]); INI_WriteInt(File, "Banned", PlayerInfo[playerid][pBanned]); INI_WriteString(File, "BannedBy", PlayerInfo[playerid][pBannedBy]); INI_WriteString(File, "Reason", PlayerInfo[playerid][pReason]); INI_Close(File); } return 1; } function SaveAccounts() { for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { SaveAccountStats(i); //Will be used to save the account stats } } } public LoadUser_data(playerid,name[],value[]) { INI_Int("Password",PlayerInfo[playerid][pPass]); INI_Int("Cash",PlayerInfo[playerid][pCash]); INI_Int("Admin",PlayerInfo[playerid][pAdmin]); INI_Float("PosX",PlayerInfo[playerid][pXPos]); INI_Float("PosY",PlayerInfo[playerid][pYPos]); INI_Float("PosZ",PlayerInfo[playerid][pZPos]); INI_Float("PosA",PlayerInfo[playerid][pAPos]); INI_Int("Skin",PlayerInfo[playerid][pSkin]); INI_Int("UCAdmin",PlayerInfo[playerid][pUCAdmin]); INI_Int("DriverLicense",PlayerInfo[playerid][pDriverLicense]); INI_Int("Hours",PlayerInfo[playerid][hours]); INI_Int("Minutes",PlayerInfo[playerid][minutes]); INI_Int("Seconds",PlayerInfo[playerid][seconds]); INI_Int("InJail",PlayerInfo[playerid][pInJail]); INI_Int("InJailTime",PlayerInfo[playerid][pInJailTime]); INI_Int("Banned", PlayerInfo[playerid][pBanned]); INI_String("BannedBy", PlayerInfo[playerid][pBannedBy],30); INI_String("ReasonBanned", PlayerInfo[playerid][pReason], 128); return 1; } forward SpectateFix(playerid); public SpectateFix(playerid) { SpawnPlayer(playerid); return true; }