[Bug] Spawn under map
#1

(sorry for bad english, i use ****** translation)

Good evening.

I'm trying to train myself to do a little GM (just to train me so neither DM, PR etc ...) and for that I'll get some stuff on the net (that I know has been doing this for 3 days , so I do not know the Pawn (I know just make orders m'kay?).

So I searched all day a system that keeps your skin to disconnect and you gave it to reconnect. I found, I installed (it also holds money, life, and weapons).
I was very happy finally I will not develop in short everything.

Tonight I found that I really needed a system that saves your coordinated disconnection, and give you where you were in again.
The trouble is:

When I create a new account, I click spawn (this button also annoys me how to remove it?) And then my character falls into the void (in the map) and then lands on a sidewalk without taking any damage to the coordinates 132.0013, -67.2916,1.5781 (I / save where I'm falling). But I have put a AddPlayerClass in OnGameModeInit ... With the coordinates of the station.

So my character should not appear before the station? I will expose my script, it'll probably make you laugh but I am doing copy paste of what I found on the internet (if I changed the credits, it's just nice to do but I don ' not that GM would use it just to train me and find out):

Quote:

#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;
}

This is after the rest is soon so I'll not take up more space on the topic.
What is wrong please? I had a FS account registration, I thought at first it was from there, so I disabled it but apparently it changes anything, I always fall in the same place at the character creation.

Namely it good backup positions and if I reconnect I appear right where I disconnected.

I thank from my heart the people who can help me.

(The system backup position I added it in and OnplayerSpawn OnPlayerDisconnect. I found here http://forum.ragezone.com/f500/tutor...-spawn-699593/).

Thank you!
Reply
#2

Nobody can say why ?
Reply
#3

if you mean the you're falling when you spawn, it's because of z coordinate, your game/net is slow so objects doesn't load so fast, and before they load you get spawned to fall. then you should make z coordinate little bigger.
Like z+1.

And good luck with your gamemode.
By the way, next time past only the error part
Reply
#4

Have you learned about timers? you can try setting a timer. TogglePlayerControllable(playerid,0);
then set timer for one second, TogglePlayerControllable(playerid,1);

to give the objects time to load

EG:

pawn Код:
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;
}
That may do the job 2 second timer to freeze the player when they spawn. Its in Milliseconds so you may want to change it to your taste. Once the timer dies, it sets them to controllable again
Reply
#5

Thank for your reply but i think you haven't understand my problem.

When i create i new character on the server (so a new account),I SPAWN UNDER THE MAP AT 0;0;0;0 POSITION. instand of spawn next to the station (1769.8235,-1862.7141,13.5760).
When i do like you say, i'm FREEZE UNDER THE MAP (so i spawn UNDER THE MAP and is not because my server it slow) and i can't moove. But i still spawn in 0;0;0;0 ... I don't understand why.

Nobody know why? Nobody have a save emplacement spawn for me please?

(Sorry i don't use ****** Translation here)
Reply
#6

Is the position actually saving to a file? what you should try doing is connecting. Then disconnecting and see if anything is actually saved.
Reply
#7

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
Reply
#8

I've try another FS but it's the same problem, when i spawn for the first time i spawn under map ( 0;0;0 ). But with this FS, he save my position *.* and load it when i spawn.

But where's the problem? Why i spawn under the map (and not next to the station train)?

EDIT : I've try all i can do... Nothing work because i've find the problem.

My save position system do SetPlayerPos(playerid,positionx,positiony,position z) in OnPlayerSpawn

So, same if i've a addplayerclass in OnPlayerModeInit, i spawn under the map in 0;0;0;0 because OnPlayerModeInit is ignorate.

So i think i need someone like :

if the first connexion
spawn next to station train
else if the second or more connexions
spawn at position save in the file, so SetPlayerPos(playerid,positionx,positiony,position z)

How can i do this?

I've do :

new Fspawn (for First Spawn),

In OnPlayerRequestClass (i've try also with OnGameInit) i've do Fspawn = 1
And in OnPlayerSpawn i've do : if ((Fspawn) == 1)
AddPlayerClass etc...

But don't work...

Please help me

I've do a new topic more explicit
Reply
#9

Quote:
Originally Posted by Paradis
Посмотреть сообщение
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
This is the saved position? in the userfiles? then the scripts gone wrong if it's saving it like that i'm afraid.
Reply
#10

I've try another script who save. But i still spawn 0;0;0 look here : https://sampforum.blast.hk/showthread.php?tid=441213
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)