24.06.2011, 18:24
So i have a way of saving and loading player locations, cash, health, etc. and i made it so its expandable when i need it to expand. however, when i have one person on the server, and someone else comes on it doesn't work, and just sends the other person through the regular login stage.
that is the code pertaining directly to what i have made, if it helps i will be willing to post my entire game mode if needed.
Код:
public OnPlayerRequestClass(playerid, classid) { if(newplayer) { SetPlayerPos(playerid, 213.204772,1822.586059,6.414062); SetPlayerCameraPos(playerid, 220.138595,1822.897583,7.525222); SetPlayerCameraLookAt(playerid, 213.204772,1822.586059,6.414062); } else { SetSpawnInfo(playerid, 0, gPlayerData[playerid][PLAYER_SKIN], spawnx, spawny, spawnz, spawnzr, 0, 0, 0, 0, 0, 0); SetTimerEx("Spawn",1,false,"i",playerid); } return 1; } public LoadPlayerData(playerid, name[], value[]) { INI_String("PASSWORD", Passwords[playerid], 64); INI_Float("PLAYER_HEALTH", health); INI_Int("PLAYER_MONEY", gPlayerData[playerid][PLAYER_MONEY]); INI_Float("POSX", spawnx); INI_Float("POSY", spawny); INI_Float("POSZ", spawnz); INI_Float("ROTZ", spawnzr); INI_Int("SKIN", gPlayerData[playerid][PLAYER_SKIN]); return 1; } public SavePlayerData(playerid, name[]) { new string[256]; format(string,256,"Players/%s.txt",name); new INI:acc = INI_Open(string); INI_WriteString(acc, "PASSWORD", Passwords[playerid]); INI_WriteFloat(acc, "PLAYER_HEALTH", health); INI_WriteInt(acc, "PLAYER_MONEY", gPlayerData[playerid][PLAYER_MONEY]); INI_WriteFloat(acc, "POSX", spawnx); INI_WriteFloat(acc, "POSY", spawny); INI_WriteFloat(acc, "POSZ", spawnz); INI_WriteFloat(acc, "ROTZ", spawnzr); INI_WriteInt(acc, "SKIN", gPlayerData[playerid][PLAYER_SKIN]); INI_Close(acc); // Close the file return 1; } public OnPlayerConnect(playerid) { newplayer = false; new playerfile[64], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(playerfile, sizeof(playerfile), "Players/%s.txt", name); if (fexist(playerfile)) { INI_ParseFile(playerfile,"LoadPlayerData", .bExtra=true, .extra=playerid); } else { health = 50; gPlayerData[playerid][PLAYER_MONEY] = 10000; newplayer = true; } new string[44], stringy[44]; GetPlayerName(playerid, name, sizeof(name)); format(string, sizeof(string), "%s has joined the server",name); SendClientMessageToAll(0xFFFFFFFF, string); format(stringy, sizeof(stringy), "Welcome, %s",name); GameTextForPlayer(playerid, stringy, 3000, 1); SetPlayerHealth(playerid, health); return 1; } public OnPlayerDisconnect(playerid,reason) { new playerfile[64], name[MAX_PLAYER_NAME], string[64]; GetPlayerName(playerid, name, sizeof(name)); format(playerfile, sizeof(playerfile), "Players/%s.txt", name); GetPlayerHealth(playerid, health); GetPlayerPos(playerid, spawnx, spawny, spawnz); GetPlayerFacingAngle(playerid, spawnzr); gPlayerData[playerid][PLAYER_SKIN] = GetPlayerSkin(playerid); SavePlayerData(playerid, name); format(string, sizeof(string), "%s has left the server",name); SendClientMessageToAll(0xFFFFFFFF, string); return 1; } public Spawn(playerid) { SpawnPlayer(playerid); } public OnPlayerSpawn(playerid) { if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC. { new npcname[MAX_PLAYER_NAME]; GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name. if(!strcmp(npcname, "Steve_Burns", true)) //Checking if the NPC's name is MyFirstNPC { PutPlayerInVehicle(playerid, stevehotdogvan, 0); //Putting the NPC into the vehicle we created for it. SetPlayerSkin(playerid, 29); } else if(!strcmp(npcname, "Jim", true)) //Checking if the NPC's name is MyFirstNPC { PutPlayerInVehicle(playerid, jimscar, 0); //Putting the NPC into the vehicle we created for it. SetPlayerSkin(playerid, 29); } return 1; } return 1; }