Spawn in Blueberry
#1

Ok here is the situation.

1) I register and it saves my cords into my database.
2) I log off then when I log in again it spawns me at blueberry and not the cords (It saves my cords on logoff).
3) then my cords get set to blueberry when I /q because I /q'ed there.

How can I fix it so it spawns me at the cords where I logged off.

pastebin: http://pastebin.com/KrXzw41e

+2 rep for the person who solves this.
Reply
#2

The Problem is in "OnPlayerSpawn" !!
Reply
#3

At first, PosX,PosY,PosZ should have a Float type.
Then, you don't get value position after login
Reply
#4

Quote:
Originally Posted by JM_Millers
Посмотреть сообщение
At first, PosX,PosY,PosZ should have a Float type.
Then, you don't get value position after login
Ok, Can you help explaining how I'd go about doing this?

I guess you mean on my enum I should do "Float: PosX" etc.
Reply
#5

I didn't read the whole script but i see there is a mistake in your enum, PosX,PosY,PosZ should be floats because there will a "dot" in the position coordinates like (234.45, 223.2521, 171.5689). So it should be like:

pawn Код:
enum pInfo {
    ID,
    Name[MAX_PLAYER_NAME],
    Password[129],
    Level,
    Admin,
    AdminTitle[64],
    Float:Health,
    Float:Armour,
    bool:IsLoggedIn,
    bool:IsRegistered,
    LoginAttempts,
    Float:PosX,
    Float:PosY,
    Float:PosZ,
}
Reply
#6

Quote:
Originally Posted by Juvanii
Посмотреть сообщение
I didn't read the whole script but i see there is a mistake in your enum, PosX,PosY,PosZ should be floats because there will a "dot" in the position coordinates like (234.45, 223.2521, 171.5689). So it should be like:

pawn Код:
enum pInfo {
    ID,
    Name[MAX_PLAYER_NAME],
    Password[129],
    Level,
    Admin,
    AdminTitle[64],
    Float:Health,
    Float:Armour,
    bool:IsLoggedIn,
    bool:IsRegistered,
    LoginAttempts,
    Float:PosX,
    Float:PosY,
    Float:PosZ,
}
Ok, as mentioned someone said my OnPlayerSpawn doesn't reference them or select it from the MySQL Database to spawn them, any help on that?
Reply
#7

Quote:
Originally Posted by JordanDoughty
Посмотреть сообщение
Ok, as mentioned someone said my OnPlayerSpawn doesn't reference them or select it from the MySQL Database to spawn them, any help on that?
Nothing is wrong with your OnPlayerSpawn callback. Try this:

pawn Код:
stock SetPlayerData(playerid)
{
    Player[playerid][ID] = cache_get_field_content_int(0, "id");
    cache_get_field_content(0, "password", Player[playerid][Password], SQL, 129);
    //The password is a varchar so you need to use cache_get_field_content
    Player[playerid][Admin] = cache_get_field_content_int(0,"admin");
    Player[playerid][Health] = cache_get_field_content_float(0, "health");
    Player[playerid][Armour] = cache_get_field_content_float(0, "armour");
   
    cache_get_field_content(0, "admintitle", Player[playerid][AdminTitle], SQL, 64);
    //the admin title is a varchar so it is again retrieved by cache_get_field_content.
    Player[playerid][Level] = cache_get_field_content_int(0,"level");
    //the level is an integer.

    Player[playerid][PosX] = cache_get_field_content_float(0, "PosX"); //Since player's position is a float, we use cache_get_field_content_float
    Player[playerid][PosY] = cache_get_field_content_float(0, "PosY");
    Player[playerid][PosZ] = cache_get_field_content_float(0, "PosZ");
    return 1;
}
Reply
#8

Quote:
Originally Posted by Cypress
Посмотреть сообщение
Nothing is wrong with your OnPlayerSpawn callback. Try this:

pawn Код:
stock SetPlayerData(playerid)
{
    Player[playerid][ID] = cache_get_field_content_int(0, "id");
    cache_get_field_content(0, "password", Player[playerid][Password], SQL, 129);
    //The password is a varchar so you need to use cache_get_field_content
    Player[playerid][Admin] = cache_get_field_content_int(0,"admin");
    Player[playerid][Health] = cache_get_field_content_float(0, "health");
    Player[playerid][Armour] = cache_get_field_content_float(0, "armour");
   
    cache_get_field_content(0, "admintitle", Player[playerid][AdminTitle], SQL, 64);
    //the admin title is a varchar so it is again retrieved by cache_get_field_content.
    Player[playerid][Level] = cache_get_field_content_int(0,"level");
    //the level is an integer.

    Player[playerid][PosX] = cache_get_field_content_float(0, "PosX"); //Since player's position is a float, we use cache_get_field_content_float
    Player[playerid][PosY] = cache_get_field_content_float(0, "PosY");
    Player[playerid][PosZ] = cache_get_field_content_float(0, "PosZ");
    return 1;
}
Worked Thanks! +rep
Reply


Forum Jump:


Users browsing this thread: