Saves points but resets after reconnect/spawn
#1

Player kills player, gives first player a score. Did that.
Writes to a file, did that. loads score when player connects.
only when you hit spawn after selecting class does it reset the score. Dont want that, want it to give back saved score. But it saves and loads my money just fine.

Code from gamemode:
Код:
public OnPlayerSpawn(playerid)
{
	if(GetPVarInt(playerid, "Dead")) {
    	SetPlayerPos(playerid, 2027.6873,-1420.3046,16.9922); // Position of the hospital.
    	DeletePVar(playerid, "Dead");
	}
	
	return 1;
}
Code from accounts FS:
Код:
CMD:login( playerid, params[ ] )
{
    new file[ 256 ], Passw[ 500 ]; format( file, sizeof file, DIRECTORY, pName( playerid ) );
    INI_ParseFile(file, "Pass", false, true, playerid);
    GetPVarString( playerid, "pPass", Passw, sizeof Passw );
	if( GetPVarInt( playerid, "pLog" ) == 1 ) return SystemMsg( playerid, "You have already logged-in." );
	if( !INI_Exist ( pName( playerid ) ) ) return SystemMsg( playerid, "This name is not registered. /register password for free $150,000!" );
	if( isnull ( params ) ) return SystemMsg( playerid, "Usage: /login [password]" );
	if( strcmp ( Passw, params, false ) == 0 )
	{
		SetPlayerScore( playerid, GetPVarInt( playerid, "pScore" ) );
		GivePlayerMoney( playerid, GetPVarInt( playerid, "pCash" ) );
		SetPVarInt( playerid, "pLog", 1 );
		SystemMsg( playerid, "You have successfully logged-in." );
	}else SystemMsg( playerid, "Wrong Credentials!" );
	return ( 1 );
}

public Pass( playerid, name[ ], value[ ] )
{
	if( !strcmp ( name, "Password" ) )
	{
		SetPVarString( playerid, "pPass", value );
	}
}

public LoadpUser( playerid, name[ ], value[ ] )
{
	if( !strcmp ( name, "Money" ) )
	{
		SetPVarInt( playerid, "pCash", strval( value ) );
	}
	if( !strcmp ( name, "Score" ) )
	{
		SetPVarInt( playerid, "pScore", strval( value ) );
	}
}
Reply
#2

Bump!
Anyone know why it saves the score but deletes them everytime people Spawn at beginning of connecting to server?
Reply
#3

Use SetPlayerScore(playerid, scorevariable[playerid]) under OnPlayerSpawn is probably your best fail-safe way to do it.
Reply
#4

Only thing that wouldnt bring up errors was adding GetPlayerScore( playerid ); under playerrequestspawn so hopefully it works, gonna have to wait for someone to join to ge able to get a point.
Reply
#5

Quote:
Originally Posted by nmader
Посмотреть сообщение
Use SetPlayerScore(playerid, scorevariable[playerid]) under OnPlayerSpawn is probably your best fail-safe way to do it.
Nope. Still doesn't load the score.
Reply
#6

As SOON as i /login password my score goes to 0.
Any Ideas?

Код:
CMD:login( playerid, params[ ] )
{
    new file[ 256 ], Passw[ 500 ]; format( file, sizeof file, DIRECTORY, pName( playerid ) );
    INI_ParseFile(file, "Pass", false, true, playerid);
    GetPVarString( playerid, "pPass", Passw, sizeof Passw );
	if( GetPVarInt( playerid, "pLog" ) == 1 ) return SystemMsg( playerid, "You have already logged-in." );
	if( !INI_Exist ( pName( playerid ) ) ) return SystemMsg( playerid, "This name is not registered. /register password for free $150,000!" );
	if( isnull ( params ) ) return SystemMsg( playerid, "Usage: /login [password]" );
	if( strcmp ( Passw, params, false ) == 0 )
	{
		GivePlayerMoney( playerid, GetPVarInt( playerid, "pCash" ) );
		SetPVarInt( playerid, "pLog", 1 );
		SystemMsg( playerid, "You have successfully logged-in." );
		SetPlayerScore( playerid, GetPVarInt( playerid, "pScore" ) );
	}else SystemMsg( playerid, "Wrong Credentials!" );
	return ( 1 );
}
Reply
#7

what are the eunms for saving the score
Reply
#8

Quote:
Originally Posted by AroseKhanNaizi
Посмотреть сообщение
what are the eunms for saving the score
Код:
enum Info
{
	AdminLevel,
	Cash,
	Score,
}
I'm using an accounts filterscript to handle login/register.
and burridge saver to save money and score.

EDIT: If I could have a login, register, money, score saving script in my gamemode i would. it had ladmin but it had a bunch of shit that did nothing and commenting it out made the script run better without dealing with warnings and errors.
Reply
#9

better make it one filter script and there might be somthing that sets score to 0 on player spawn see in ur filter script if nothing is there set it
pawn Код:
SetPlayerScore(playerid,/*variabale used for info enum */[playerid][Score]);
Reply
#10

Quote:
Originally Posted by AroseKhanNaizi
Посмотреть сообщение
better make it one filter script and there might be somthing that sets score to 0 on player spawn see in ur filter script if nothing is there set it
pawn Код:
SetPlayerScore(playerid,/*variabale used for info enum */[playerid][Score]);
So I tried to merge the two and this is what I got.
It...kinda works...doesnt write password to file, only score and money..and it doesnt give 150k after registering like it used to..it just says You already have an account, then says i should login. i think they are two different file writing systems..

Код:
/*******************************************************************************
Burridge's Score System By Daniel Burridge
*******************************************************************************/
//*********************************INCLUDES***********************************//
#include <a_samp>
#include    < zcmd >
#include <Dini>
#include <Dutils>
#include <Dudb>
#include < YSI\y_ini >
#include    < YDB  >
#define COLOR_SYSTEM 	(0xEFEFF7AA)
#define green 			(0x33FF33AA)
#define blue 			(0x00FFFFAA)
#define StartMoney 150000
#define DIRECTORY       "Accounts/%s.ini"
//*******************************PRAGMAS**************************************//
#pragma unused ret_memcpy
//**FORWARDS**//
forward BuridgeDisconnect(playerid);
forward BuridgeConnect(playerid);
forward Pass( playerid, name[ ], value[ ] );
forward LoadpUser( playerid, name[ ], value[ ] );
//**************************************NEWS**********************************//
new pname[MAX_PLAYER_NAME];
new BurridgeScore[100];
/*---------------------------------CallBacks----------------------------------*/
public BuridgeDisconnect(playerid)
{
    GetPlayerName(playerid, pname, sizeof(pname));
    format(BurridgeScore, sizeof(BurridgeScore), "Accounts/%s.ini",pname);
    if(!dini_Exists(BurridgeScore)) {
    }
    else {
        dini_IntSet(BurridgeScore, "Score", GetPlayerScore(playerid));
        dini_IntSet(BurridgeScore, "Money", GetPlayerMoney(playerid));
    }
}

public OnPlayerRequestSpawn( playerid )
{

	if( INI_Exist ( pName( playerid ) ) )
	{
		if( GetPVarInt( playerid, "pLog" ) == 0 )
		{
			SendClientMessage( playerid, green, "This name is already registered. Please /login password to login to this account. ");
			return ( 0 );
		}
	}
	return ( 1 );
}


public BuridgeConnect(playerid)
{
    if( GetPVarInt( playerid, "pLog" ) == 0 )
	{
		if( INI_Exist ( pName( playerid ) ) )
		{
			SystemMsg( playerid, "This name is already registered. Please /login [password] to login." );
		}
		else SystemMsg( playerid, "This name is not registered. /register password for free $150,000!" );
	}
    GetPlayerName(playerid, pname, sizeof(pname));
    format(BurridgeScore, sizeof(BurridgeScore), "Accounts/%s.ini",pname);
    if(!dini_Exists(BurridgeScore)) {
        dini_Create(BurridgeScore);
        dini_IntSet(BurridgeScore, "Score", 0);
        dini_IntSet(BurridgeScore, "Money", 0);
        SetPlayerScore(playerid, dini_Int(BurridgeScore, "Score"));
        SetPlayerMoney(playerid, dini_Int(BurridgeScore, "Money"));
    }
    else {
        SetPlayerScore(playerid, dini_Int(BurridgeScore, "Score"));
        SetPlayerMoney(playerid, dini_Int(BurridgeScore, "Money"));
    }
    return 1;
}



public OnPlayerConnect(playerid)
{
    BuridgeConnect(playerid);
    return 1;
}


public OnPlayerDisconnect(playerid)
{
    BuridgeDisconnect(playerid);
    return 1;
}

stock SystemMsg( playerid, msg[ ] )
{
   if( ( IsPlayerConnected ( playerid ) ) && ( strlen ( msg ) > 0 ) ) SendClientMessage( playerid, COLOR_SYSTEM, msg );
   return ( 1 );
}

stock pName( playerid )
{
	new name[ MAX_PLAYER_NAME ];
	GetPlayerName( playerid, name, sizeof name );
	return name;
}

CMD:register( playerid, params[ ] )
{

    new file[ 256 ]; format( file, sizeof file, DIRECTORY, pName( playerid ) );
    new INI:PlayerAcc = INI_Open( file );
	if( GetPVarInt( playerid, "pLog" ) == 1 ) return SystemMsg( playerid, "You already have an account." );
	if( INI_Exist( pName( playerid ) ) ) return SystemMsg( playerid, "You already have an account, /login [password] to login." );
	if( strlen ( params ) == 0 ) return SystemMsg( playerid, "Usage: /register [password]" );
    SystemMsg( playerid, "You have successfully created your account. Please /login [password] to login." );
    GivePlayerMoney(playerid, StartMoney);
    INI_WriteString( PlayerAcc, "Name", pName( playerid ) );
    INI_WriteString( PlayerAcc, "Password", params );
    INI_Close( PlayerAcc );
	return ( 1 );
}

CMD:login( playerid, params[ ] )
{
    new file[ 256 ], Passw[ 500 ]; format( file, sizeof file, DIRECTORY, pName( playerid ) );
    INI_ParseFile(file, "Pass", false, true, playerid);
    GetPVarString( playerid, "pPass", Passw, sizeof Passw );
	if( GetPVarInt( playerid, "pLog" ) == 1 ) return SystemMsg( playerid, "You have already logged-in." );
	if( !INI_Exist ( pName( playerid ) ) ) return SystemMsg( playerid, "This name is not registered. /register password for free $150,000!" );
	if( isnull ( params ) ) return SystemMsg( playerid, "Usage: /login [password]" );
	if( strcmp ( Passw, params, false ) == 0 )
	{
		GivePlayerMoney( playerid, GetPVarInt( playerid, "pCash" ) );
		SetPVarInt( playerid, "pLog", 1 );
		SystemMsg( playerid, "You have successfully logged-in." );
		SetPlayerScore( playerid, GetPVarInt( playerid, "pScore" ) );
	}else SystemMsg( playerid, "Wrong Credentials!" );
	return ( 1 );
}


public Pass( playerid, name[ ], value[ ] )
{
	if( !strcmp ( name, "Password" ) )
	{
		SetPVarString( playerid, "pPass", value );
	}
}

public LoadpUser( playerid, name[ ], value[ ] )
{
	if( !strcmp ( name, "Money" ) )
	{
		SetPVarInt( playerid, "pCash", strval( value ) );
	}
	if( !strcmp ( name, "Score" ) )
	{
		SetPVarInt( playerid, "pScore", strval( value ) );
	}
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)