#include <a_samp> #include <core> #include <float> #include <Dutils> #include <Dudb> #include <Dini> #define savefolder "/save/%s.ini" #pragma unused ret_memcpy new Killz[MAX_PLAYERS]; new Deathz[MAX_PLAYERS]; main() { print("\n ----------------------------------"); print(" | |"); print(" | |"); print(" | .: [FR] CannaWeed Serveur :. |"); print(" | 0.1 Server Version |"); print(" | |"); print(" ----------------------------------\n"); } #define COLOR_YELLOW 0xFFFF00FF #define ACTION_COLOR 0x400080FF #define COLOR_RED 0xFF0000FF public OnGameModeInit() { // Don't use these lines if it's a filterscript SetGameModeText("CannaWeed"); AddPlayerClass(26,1769.8235,-1862.7141,13.5760,359.7843,0,0,0,0,0,0); // SPAWN return 1; } public OnGameModeExit() { return 1; } public OnPlayerRequestClass(playerid, classid) { new pname[128]; new file[128]; GetPlayerName(playerid, pname, sizeof(pname)); format(file, sizeof(file), savefolder,pname); if(!dini_Exists(file)) { dini_Create(file); dini_IntSet(file, "Score", 0); dini_IntSet(file, "Money", 0); dini_IntSet(file, "Kills", Killz[playerid]); dini_IntSet(file, "Deaths", Deathz[playerid]); dini_IntSet(file, "Skin", 0); SetPlayerScore(playerid, dini_Int(file, "Score")); SetPlayerMoney(playerid, dini_Int(file, "Money")); SetPlayerSkin(playerid, dini_Int(file, "Skin")); } else { SetPlayerScore(playerid, dini_Int(file, "Score")); SetPlayerMoney(playerid, dini_Int(file, "Money")); SetPlayerSkin(playerid, dini_Int(file, "Skin")); SetPlayerPos(playerid,1769.8235,-1862.7141,13.5760); SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746); SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746); return 1; } return 0; } public OnPlayerConnect(playerid) { new pname[128]; new file[128]; GetPlayerName(playerid, pname, sizeof(pname)); format(file, sizeof(file), savefolder,pname); if(!dini_Exists(file)) { dini_Create(file); dini_IntSet(file, "Score", 0); dini_IntSet(file, "Money", 0); dini_IntSet(file, "Kills", Killz[playerid]); dini_IntSet(file, "Deaths", Deathz[playerid]); dini_IntSet(file, "Skin", 0); SetPlayerScore(playerid, dini_Int(file, "Score")); SetPlayerMoney(playerid, dini_Int(file, "Money")); SetPlayerSkin(playerid, dini_Int(file, "Skin")); SendClientMessage(playerid,0x008000FF,"Bienvenue sur .: [FR] CannaWeed Serveur :."); SendClientMessage(playerid,0xFF0000FF,"Veuillez vous dйconnectez aprиs la crйation de votre compte pour enregistrer les donnйs"); SendClientMessage(playerid,0xFFFF00FF," Astuce: Pour avoir accиs а la liste des commandes, tapez /commandes"); SendClientMessage(playerid,COLOR_RED,"Cliquez sur SPAWN en bas a droite pour apparaitre une fois loggй!"); } else { SendClientMessage(playerid,0x008000FF,"Bienvenue sur .: [FR] CannaWeed Serveur :."); SendClientMessage(playerid,0xFF0000FF,"Veuillez vous dйconnectez aprиs la crйation de votre compte pour enregistrer les donnйs"); SendClientMessage(playerid,0xFFFF00FF," Astuce: Pour avoir accиs а la liste des commandes, tapez /commandes"); SendClientMessage(playerid,COLOR_RED,"Cliquez sur SPAWN en bas a droite pour apparaitre une fois loggй!"); SetPlayerScore(playerid, dini_Int(file, "Score")); SetPlayerMoney(playerid, dini_Int(file, "Money")); SetPlayerSkin(playerid, dini_Int(file, "Skin")); return 1; } return 0; } public OnPlayerDisconnect(playerid, reason) { { new pname[128]; new file[128]; GetPlayerName(playerid, pname, sizeof(pname)); format(file, sizeof(file), savefolder,pname); if(!dini_Exists(file)) { } else { dini_IntSet(file, "Score", GetPlayerScore(playerid)); dini_IntSet(file, "Money", GetPlayerMoney(playerid)); dini_IntSet(file, "Kills", Killz[playerid]); dini_IntSet(file, "Deaths", Deathz[playerid]); dini_IntSet(file, "Skin", GetPlayerSkin(playerid)); new Float, Float:y, Float:z; GetPlayerName(playerid, pname, sizeof(pname)); format(file, sizeof(file), "\\SavePos\\%s.ini", pname); if(!dini_Exists(file)) dini_Create(file); GetPlayerPos(playerid, x, y, z); dini_FloatSet(file, "posX", x); dini_FloatSet(file, "posY", y); dini_FloatSet(file, "posZ", z); return 1; } return 0; } } public OnPlayerSpawn(playerid) { new file[128], pname[MAX_PLAYER_NAME]; new Float, Float:y, Float:z; GetPlayerName(playerid, pname, sizeof(pname)); format(file, sizeof(file), "\\SavePos\\%s.ini", pname); x = dini_Float(file, "posX"); y = dini_Float(file, "posY"); z = dini_Float(file, "posZ"); SetPlayerPos(playerid, x,y,z); return 1; } public OnPlayerDeath(playerid, killerid, reason) { return 1; } public OnVehicleSpawn(vehicleid) { return 1; } public OnVehicleDeath(vehicleid, killerid) { return 1; } public OnPlayerText(playerid, text[]) { return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/commandes", cmdtext, true, 10) == 0) { SendClientMessage(playerid,COLOR_YELLOW,"Commandes Gйnйrales : /aide general"); SendClientMessage(playerid,COLOR_YELLOW,"Commandes Factions : /aide faction"); SendClientMessage(playerid,COLOR_YELLOW,"Liste des animations : /animlist"); return 1; } return 0; } public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { return 1; } |
public OnPlayerSpawn(playerid)
{
new file[128], pname[MAX_PLAYER_NAME];
new Float, Float:y, Float:z;
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), "\\SavePos\\%s.ini", pname);
x = dini_Float(file, "posX");
y = dini_Float(file, "posY");
z = dini_Float(file, "posZ");
SetPlayerPos(playerid, x,y,z);
SetTimerEx("spawn",2000,false,"i",playerid);
TogglePlayerControllable(playerid,0);
return 1;
}
forward spawn(playerid);
public spawn(playerid)
{
TogglePlayerControllable(playerid,1);
return 1;
}
The position save is
x=0.00000 y=0.00000 z=0.00000 But i know that when i do the script of OnPlayerSpawn in OnPlayerConnect saving to a file. I'm not sure but tomorrow i've sucessful at save someone after do in OnPlayerConnect (so the same in OnPlayerSpawn and OnPlayerConnect). But same when i do that i spawn under the map at 0;0;0 (i don't know if you understand what i write xD). It may be the script which is obsolete for 0.3x ? I need a script like him |