save position
#1

hi everyone i want to ask how to save last position who someone play! I have Y_SI and other stuff but maybe i miss something??
Reply
#2

use getplayer position onplayerdisconnect and save those xyz to ini and load on playerconnect use onplayerspawn
Reply
#3

Save Position when playerdisconnect

pawn Код:
#define UserPath "Users/%s.ini" /
public OnPlayerDisconnect(playerid, reason)
{
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);

new INI:file = INI_Open(paths(playerid));

        INI_WriteFloat(pathfile, "PosX", x);
        INI_WriteFloat(pathfile, "PosY", y);
        INI_WriteFloat(pathfile, "PosZ", z);
        INI_Close(pathfile);
}
stock paths(playerid)
{
    new string[128],pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    format(string,sizeof(string),UserPath,pname);
    return string;
}
And Load when Player login or spawn
I'm using Dini Because I feel its use easier :P even its old lol

Cr. (made by ******) & newbienoob
Reply
#4

PHP код:
public OnPlayerDisconnect(playeridreason)
{
    new 
PName[MAX_PLAYER_NAME];
    new 
String[128];
    
GetPlayerName(playeridPNamesizeof(PName));

    switch(
reason)
    {
        case 
0format(Stringsizeof(String), "%s lost connection to the server."PName);
        case 
1format(Stringsizeof(String), "%s has left the server."PName);
        case 
2format(Stringsizeof(String), "%s has left the server. (kicked)"PName);
    }
    return 
1;

This is my disconnect for the moment... how to add this cause when try i get so manny errors
Reply
#5

PHP код:
public OnPlayerDisconnect(playeridreason)
{
    new 
PName[MAX_PLAYER_NAME];
    new 
String[128];
    
GetPlayerName(playeridPNamesizeof(PName));
    switch(
reason)
    {
        case 
0format(Stringsizeof(String), "%s lost connection to the server."PName);
        case 
1format(Stringsizeof(String), "%s has left the server."PName);
        case 
2format(Stringsizeof(String), "%s has left the server. (kicked)"PName);
    }
    return 
1;

This is my disconnect for the moment... how to add this cause when try i get so manny errors
Reply
#6

PHP код:
// Top of your script
new
    
FloatPosXMAX_PLAYERS ],
    
FloatPosYMAX_PLAYERS ],
    
FloatPosZMAX_PLAYERS ],
    
FloatAngleMAX_PLAYERS ],
    
InteriorMAX_PLAYERS ],
    
VirtualWorldMAX_PLAYERS ]
;
// Any where
stock user_ini_file(playerid)
{
    new 
        
string128 ],
        
user_nameMAX_PLAYER_NAME ]
    ;
    
GetPlayerNameplayeriduser_nameMAX_PLAYER_NAME );
    
formatstringsizeof ( string ), "%s.ini"user_name ); // < This is the Scriptfiles directory
       
return string;
}
forward @load_user_positionplayeridname[], value[] );
@
load_user_positionplayeridname[], value[] )
{
    
INI_Float"PositionX"PosXplayerid ] );
    
INI_Float"PositionY"PosYplayerid ] );
    
INI_Float"PositionZ"PosZplayerid ] );
    
INI_Float"Angle"Angleplayerid ] );
    
INI_Int"Interior"Interiorplayerid ] );
    
INI_Int"VirtualWorld"VirtualWorldplayerid ] );
    return ( 
);
}
// OnPlayerDisconnect
public OnPlayerDisconnect(playeridreason

    new 
PName[MAX_PLAYER_NAME]; 
    new 
String[128]; 
    
GetPlayerName(playeridPNamesizeof(PName)); 
    switch(
reason
    { 
        case 
0format(Stringsizeof(String), "%s lost connection to the server."PName); 
        case 
1format(Stringsizeof(String), "%s has left the server."PName); 
        case 
2format(Stringsizeof(String), "%s has left the server. (kicked)"PName); 
    } 
    
GetPlayerPosplayeridPosXplayerid ], PosYplayerid ], PosZplayerid ] );
    
GetPlayerFacingAngleplayeridAngleplayerid ] );
    
    new 
INI:File INI_Openuser_ini_fileplayerid ) );
    
INI_SetTagFile"position" );
    
INI_WriteFloatFile"PositionX"PosXplayerid ] );
    
INI_WriteFloatFile"PositionY"PosYplayerid ] );
    
INI_WriteFloatFile"PositionZ"PosZplayerid ] );
    
INI_WriteFloatFile"Angle"Angleplayerid ] );
    
INI_WriteIntFile"Interior"GetPlayerInteriorplayerid ) );
    
INI_WriteIntFile"VirtualWorld"GetPlayerVirtualWorldplayerid ) );
    
INI_CloseFile );
    return 
1
}  
// OnPlayerConnect
public OnPlayerConnectplayerid )
{
    
PosXplayerid ] = 0;
    
PosYplayerid ] = 0;
    
PosZplayerid ] = 0;
    
Angleplayerid ] = 0;
    
Interiorplayerid ] = 0;
    
VirtualWorldplayerid ] = 0;
    
    
INI_ParseFileuser_ini_fileplayerid ), "load_user_%s", .bExtra true, .extra playerid );
    return ( 
);
}
// OnPlayerSpawn
public OnPlayerSpawnplayerid )
{
    if ( 
PosXplayerid ] != && PosYplayerid ] != && PosZplayerid ] != && Angleplayerid ] != )
    {
        
SetPlayerPosplayeridPosXplayerid ], PosYplayerid ], PosZplayerid ] );
        
SetPlayerFacingAngleplayeridAngleplayerid ] );
        
SetPlayerInteriorplayeridInteriorplayerid ] );
        
SetPlayerVirtualWorldplayeridVirtualWorldplayerid ] );
    }
    return ( 
);

Thanks to SmiT.
Reply
#7

Double post // edited , make it look easier you need to change it to similar your config , variable

Fixed I think Thx for oMa37 too
Reply
#8

PHP код:
//Save Stats
new
    
FloatPosXMAX_PLAYERS ],
    
FloatPosYMAX_PLAYERS ],
    
FloatPosZMAX_PLAYERS ],
    
FloatAngleMAX_PLAYERS ],
    
InteriorMAX_PLAYERS ],
    
VirtualWorldMAX_PLAYERS ]
;
//STATS
{
new
string128 ],
user_nameMAX_PLAYER_NAME ]
;

GetPlayerNameplayeriduser_nameMAX_PLAYER_NAME );
formatstringsizeof ( string ), "%s.ini"user_name ); // < This is the Scriptfiles directory
return string;
}

forward @load_user_positionplayeridname[], value[] );

@
load_user_positionplayeridname[], value[] )
{
    
INI_Float"PositionX"PosXplayerid ] );
    
INI_Float"PositionY"PosYplayerid ] );
    
INI_Float"PositionZ"PosZplayerid ] );
    
INI_Float"Angle"Angleplayerid ] );
    
INI_Int"Interior"Interiorplayerid ] );
    
INI_Int"VirtualWorld"VirtualWorldplayerid ] );
    return ( 
);
}

//END 
PHP код:
public OnPlayerConnect(playerid)
{
    new 
pName[30], string[256];
    
GetPlayerName(playeridpName30);
    
format(string256"~w~Welcome ~n~~y~%s!"pName);
    
GameTextForPlayer(playerid,string,4000,1);
    
SendClientMessage(playeridCOLOR_WHITE"|Y|--//Добре дошъл/Welcome\\--|Y|");
    
SendClientMessage(playeridCOLOR_GREEN"|Y|--//В BULGARIA ROLE-PLAY\\--|Y|");
    
SendClientMessage(playeridCOLOR_RED"|Y|--//SERVER 0.3.7 предоставен от: Borisov313\\--|Y|");
    
SendClientMessage(playeridCOLOR_LEMON"|Y|--//За повече информация напиши /help\\--|Y|");
    
SendClientMessage(playeridCOLOR_TAN"|Y|--//Приятна игра/Enjoy the game!\\--|Y|");
    return 
1;
}
{
    
PosXplayerid ] = 0;
    
PosYplayerid ] = 0;
    
PosZplayerid ] = 0;
    
Angleplayerid ] = 0;
    
Interiorplayerid ] = 0;
    
VirtualWorldplayerid ] = 0;

    
INI_ParseFileuser_ini_fileplayerid ), "load_user_%s", .bExtra true, .extra playerid );
    return ( 
);

PHP код:
public OnPlayerDisconnect(playeridreason)
{
    new 
PName[MAX_PLAYER_NAME];
    new 
String[128];
    
GetPlayerName(playeridPNamesizeof(PName));

    switch(
reason)
    {
        case 
0format(Stringsizeof(String), "%s lost connection to the server."PName);
        case 
1format(Stringsizeof(String), "%s has left the server."PName);
        case 
2format(Stringsizeof(String), "%s has left the server. (kicked)"PName);
    }

    
GetPlayerPosplayeridPosXplayerid ], PosYplayerid ], PosZplayerid ] );
    
GetPlayerFacingAngleplayeridAngleplayerid ] );
    new 
INI:File INI_Openuser_ini_fileplayerid ) );
    
INI_SetTagFile"position" );
    
INI_WriteFloatFile"PositionX"PosXplayerid ] );
    
INI_WriteFloatFile"PositionY"PosYplayerid ] );
    
INI_WriteFloatFile"PositionZ"PosZplayerid ] );
    
INI_WriteFloatFile"Angle"Angleplayerid ] );
    
INI_WriteIntFile"Interior"GetPlayerInteriorplayerid ) );
    
INI_WriteIntFile"VirtualWorld"GetPlayerVirtualWorldplayerid ) );
    
INI_CloseFile );
    return 
1;
}

public 
OnPlayerSpawn(playerid)
{
    
//Gang Zones
    
GangZoneShowForAll (astecs0x12B0FC8B);
    
GangZoneShowForAll (grove10x008C0085);
    
GangZoneShowForAll (grove20x00950096);
    
GangZoneShowForAll (ballas0xF053FD81);
    
GangZoneShowForAll (vagos0xECEC0089);
    
GangZoneShowForAll (polis0xE800007C);
    
GangZoneShowForAll (triada0xAFAFAFAA);
    
GangZoneShowForAll (rifa0x33CCFFAA);
    
GangZoneShowForAll (sfarmy0x660000AA);
    
GangZoneShowForAll (lvarmy0x660000AA);

    if ( 
PosXplayerid ] != && PosYplayerid ] != && PosZplayerid ] != && Angleplayerid ] != )
    {
        
SetPlayerPosplayeridPosXplayerid ], PosYplayerid ], PosZplayerid ] );
        
SetPlayerFacingAngleplayeridAngleplayerid ] );
        
SetPlayerInteriorplayeridInteriorplayerid ] );
        
SetPlayerVirtualWorldplayeridVirtualWorldplayerid ] );
    }
    return 
1;

PHP код:
C:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(82) : error 055start of function body without function header
C
:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(88) : error 021symbol already defined"GetPlayerName"
C:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(90) : error 010invalid function or declaration
C
:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(97) : error 017undefined symbol "INI_Float"
C:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(98) : error 017undefined symbol "INI_Float"
C:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(99) : error 017undefined symbol "INI_Float"
C:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(100) : error 017undefined symbol "INI_Float"
C:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(101) : error 017undefined symbol "INI_Int"
C:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(102) : error 017undefined symbol "INI_Int"
C:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(209) : warning 219local variable "string" shadows a variable at a preceding level
C
:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(220) : error 055start of function body without function header
C
:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(228) : error 001expected token")"but found "("
C:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(228) : error 010invalid function or declaration
C
:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(228 -- 229) : error 010invalid function or declaration
C
:\Users\Борисов\Desktop\Crime Life Gang Wars\gamemodes\Creation.pwn(228 -- 229) : fatal error 107too many error messages on one line

Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase


14 Errors

Reply
#9

Do you have the last version of y_ini ? also did you include it in your script?

EDIT:
Change your OnPlayerConnect to this:

PHP код:
public OnPlayerConnect(playerid)
{
    new 
pName[30], string[256];
    
GetPlayerName(playeridpName30);
    
format(string256"~w~Welcome ~n~~y~%s!"pName);
    
GameTextForPlayer(playerid,string,4000,1);
    
SendClientMessage(playeridCOLOR_WHITE"|Y|--//Добре дошъл/Welcome\\--|Y|");
    
SendClientMessage(playeridCOLOR_GREEN"|Y|--//В BULGARIA ROLE-PLAY\\--|Y|");
    
SendClientMessage(playeridCOLOR_RED"|Y|--//SERVER 0.3.7 предоставен от: Borisov313\\--|Y|");
    
SendClientMessage(playeridCOLOR_LEMON"|Y|--//За повече информация напиши /help\\--|Y|");
    
SendClientMessage(playeridCOLOR_TAN"|Y|--//Приятна игра/Enjoy the game!\\--|Y|");
    
PosXplayerid ] = 0;
    
PosYplayerid ] = 0;
    
PosZplayerid ] = 0;
    
Angleplayerid ] = 0;
    
Interiorplayerid ] = 0;
    
VirtualWorldplayerid ] = 0;
    
INI_ParseFileuser_ini_fileplayerid ), "load_user_%s", .bExtra true, .extra playerid );
    return 
1;

Reply
#10

pawn Код:
#include <YSI\y_ini>
Top of Your Script
Download lastest version
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)