Help me making save score!!
#1

Please guys help me create score sytem and when player login its says (playername) has been logged in to this server for this register system (this is not mine) im very gratefull if you would like to help me for free but if you ask me to pay i would like too pay too but i hope you want to edit it for free
Код:
#include <a_samp>
#include <Double-O-Files_2>

#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode DOF2");
	print("----------------------------------\n");
}

public OnGameModeInit()
{
	SetGameModeText("Blank Script DOF2");
	return 1;
}
enum pInfo
{
	pKills,
	pDeaths,
	pMoney,
	pAdmin
}
new PlayerInfo[MAX_PLAYERS][pInfo];
//----------------------

public OnGameModeExit()
{
	DOF2_Exit();
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	return 1;
}

public OnPlayerConnect(playerid)
{
	new file[64];
    GetPlayerName(playerid,file,sizeof(file));
    format(file,sizeof(file),DOF2_File(file));// Here we get the path from DOF2_File (/Users)
	if(DOF2_FileExists(file)) // We check if the player is registered
	{
		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Welcome.Please log-in","{FFFFFF}Type your {00FF22}password {FFFFFF}here to log-in","Log-in","Quit");
	}
	else // If not registered
	{
		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Please register!","{FFFFFF}Type your {00FF22}password {FFFFFF}here to register.","Register","Quit");
	}
	return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid) // We switch the dialogs
	{
		case DIALOG_REGISTER: // If dialog_register (id 1) shows up
		{
			if(!response) Kick(playerid); // If he click on Quit, he will get kicked
			if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Please register!","{FFFFFF}Type your {00FF22}password {FFFFFF}here to register.","Register","Quit");
			// If he doesn't type anything, the dialog will show again.
			if(response) // If he click on Register
			{
				new file[64]; // We declare the size of the file
				GetPlayerName(playerid,file,sizeof(file)); // We get the file name
				format(file,sizeof(file),DOF2_File(file)); // We get the path name from DOF2_File, that means from Users folder.
				DOF2_CreateFile(file, inputtext); // Creates the file and the password.
				DOF2_SetInt(file, "Kills",PlayerInfo[playerid][pKills] = 0); // When the player register his kills will be set to 0, you can change
				DOF2_SetInt(file, "Deaths",PlayerInfo[playerid][pDeaths] = 0); // His deaths will be set to 0, you can change
				DOF2_SetInt(file, "Money",PlayerInfo[playerid][pMoney] = 1000); // His money will be set to 1000, you can change
				DOF2_SetInt(file, "AdminLevel",PlayerInfo[playerid][pAdmin] = 0); // His Admin Level will be set to 0, you can change
				DOF2_SaveFile(); // Saves the file.
				SetSpawnInfo(playerid, 0, 0, 1722.5123, -1912.7931, 13.5647, 269.15, 0, 0, 0, 0, 0, 0); // Sets where the player will spawn, this coordinates are from the Unity Station in Los Santos
				SpawnPlayer(playerid); // After registering, the player will spawn.
			}
		}
		case DIALOG_LOGIN: // If dialog_login (id 2) shows up
		{
			if(!response) Kick(playerid); // If he click on Quit, he will get kicked.
			if(response) // If he click on Log-in
			{
				new file[64]; // We declare the size of the file
				GetPlayerName(playerid,file,sizeof(file)); // We get the file name
				format(file,sizeof(file),DOF2_File(file)); // We get the user path from DOF2_File ( folder Users )
				if(DOF2_FileExists(file)) // If he is registered
				{
					if(DOF2_CheckLogin(file,inputtext)) // We check if the password match
					{
						PlayerInfo[playerid][pKills] = DOF2_GetInt(file,"Kills"); // We load our settings
						PlayerInfo[playerid][pDeaths] = DOF2_GetInt(file,"Deaths");
						PlayerInfo[playerid][pMoney] = DOF2_GetInt(file,"Money");
						PlayerInfo[playerid][pAdmin] = DOF2_GetInt(file,"AdminLevel");
						SetSpawnInfo(playerid, 0, 0, 1722.5123, -1912.7931, 13.5647, 269.15, 0, 0, 0, 0, 0, 0); // We set the spawn (Unity Station)
						SpawnPlayer(playerid); // The player spawns after log-in
						return 1;
					}
					else // If the password don't match, they will get an error
					{
						ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Wrong Password!","{F81414}You have typed a wrong password\n{FFFFFF}Type your password here to log-in!","Log-in","Quit");
						return 1;
					}
				}
			}
		}
	}
	return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
	new file[64]; // We declare the size of the file
    GetPlayerName(playerid,file,sizeof(file)); // We get the file name
    format(file,sizeof(file),DOF2_File(file));// We get the user path from DOF2_File (folder Users)
	DOF2_SetInt(file, "Kills",PlayerInfo[playerid][pKills]); // We set/update the players settings.
	DOF2_SetInt(file, "Deaths",PlayerInfo[playerid][pDeaths]);
	DOF2_SetInt(file, "Money",PlayerInfo[playerid][pMoney]);
	DOF2_SetInt(file, "AdminLevel",PlayerInfo[playerid][pAdmin]);
	return 1;
}

public OnPlayerSpawn(playerid)
{
	GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	PlayerInfo[killerid][pKills]++;
    PlayerInfo[playerid][pDeaths]++;
	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("/mycommand", cmdtext, true, 10) == 0)
	{
		// Do something here
		return 1;
	}
	return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}


public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}
Reply
#2

this one with score saving

pawn Код:
enum pInfo
{
    pKills,
    pDeaths,
    pMoney,
    pAdmin,
    pScore
}
adding pScore in the enum
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
 {
    switch(dialogid) // We switch the dialogs
    {
        case DIALOG_REGISTER: // If dialog_register (id 1) shows up
        {
            if(!response) Kick(playerid); // If he click on Quit, he will get kicked
            if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Please register!","{FFFFFF}Type your {00FF22}password {FFFFFF}here to register.","Register","Quit");
            // If he doesn't type anything, the dialog will show again.
            if(response) // If he click on Register
            {
                new file[64]; // We declare the size of the file
                GetPlayerName(playerid,file,sizeof(file)); // We get the file name
                format(file,sizeof(file),DOF2_File(file)); // We get the path name from DOF2_File, that means from Users folder.
                DOF2_CreateFile(file, inputtext); // Creates the file and the password.
                DOF2_SetInt(file, "Kills",PlayerInfo[playerid][pKills] = 0); // When the player register his kills will be set to 0, you can change
                DOF2_SetInt(file, "Deaths",PlayerInfo[playerid][pDeaths] = 0); // His deaths will be set to 0, you can change
                DOF2_SetInt(file, "Money",PlayerInfo[playerid][pMoney] = 1000); // His money will be set to 1000, you can change
                DOF2_SetInt(file, "AdminLevel",PlayerInfo[playerid][pAdmin] = 0); // His Admin Level will be set to 0, you can change
                DOF2_SetInt(file, "Score",GetPlayerScore(playerid);
                DOF2_SaveFile(); // Saves the file.
                SetSpawnInfo(playerid, 0, 0, 1722.5123, -1912.7931, 13.5647, 269.15, 0, 0, 0, 0, 0, 0); // Sets where the player will spawn, this coordinates are from the Unity Station in Los Santos
                SpawnPlayer(playerid); // After registering, the player will spawn.
            }
        }
        case DIALOG_LOGIN: // If dialog_login (id 2) shows up
        {
            if(!response) Kick(playerid); // If he click on Quit, he will get kicked.
            if(response) // If he click on Log-in
            {
                new file[64]; // We declare the size of the file
                GetPlayerName(playerid,file,sizeof(file)); // We get the file name
                format(file,sizeof(file),DOF2_File(file)); // We get the user path from DOF2_File ( folder Users )
                if(DOF2_FileExists(file)) // If he is registered
                {
                    if(DOF2_CheckLogin(file,inputtext)) // We check if the password match
                    {
                        PlayerInfo[playerid][pKills] = DOF2_GetInt(file,"Kills"); // We load our settings
                        PlayerInfo[playerid][pDeaths] = DOF2_GetInt(file,"Deaths");
                        PlayerInfo[playerid][pMoney] = DOF2_GetInt(file,"Money");
                        PlayerInfo[playerid][pAdmin] = DOF2_GetInt(file,"AdminLevel");
                        PlayerInfo[playerid][pScore] = DOF2_GetInt(file,"Score");
                                                SetPlayerScore(playerid,PlayerInfo[playerid][pScore]);
                        SetSpawnInfo(playerid, 0, 0, 1722.5123, -1912.7931, 13.5647, 269.15, 0, 0, 0, 0, 0, 0); // We set the spawn (Unity Station)
                        new Name[MAX_PLAYER_NAME];
                        GetPlayerName(playerid,Name,sizeof(Name));
                        new S[128];
                        format(S,sizeof(S)," player %s(%d) has logged in",Name,playerid);
                        SendClientMessageToAll(-1,S);
                        SpawnPlayer(playerid); // The player spawns after log-in
                        return 1;
                    }
                    else // If the password don't match, they will get an error
                    {
                        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Wrong Password!","{F81414}You have typed a wrong password\n{FFFFFF}Type your password here to log-in!","Log-in","Quit");
                        return 1;
                    }
                }
            }
        }
    }
    return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
    new file[64]; // We declare the size of the file
         GetPlayerName(playerid,file,sizeof(file)); // We get the file name
        format(file,sizeof(file),DOF2_File(file));// We get the user path from DOF2_File (folder Users)
    DOF2_SetInt(file, "Kills",PlayerInfo[playerid][pKills]); // We set/update the players settings.
    DOF2_SetInt(file, "Deaths",PlayerInfo[playerid][pDeaths]);
    DOF2_SetInt(file, "Money",PlayerInfo[playerid][pMoney]);
    DOF2_SetInt(file, "AdminLevel",PlayerInfo[playerid][pAdmin]);
        DOF2_SetInt(file, "Score",GetPlayerScore(playerid);
    return 1;
}
done ^^
Reply
#3

how about if player connect its says (player name) has connected to the game REP++
Reply
#4

A simple use of SendClientMessage, yet i forgot how to make it since i dont use it myself xD
Reply
#5

This will tell everyone on the server that (player name) has connected to the server..

Under public OnPlayerConnect(playerid)

new name[MAX_PLAYER_NAME], str[32+MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(str, sizeof(str), "%s has connected to the server.", name);
SendClientMessageToAll(0xFFFFFFAA, str);
Reply
#6

my game is not saving guys and its not showing (player) has lgged in
Reply
#7

can someone fix the script and give me the working pwn file that can save? please? i will send 0.5$ money to your paypal if you can fix it and all of the save system working and message when player login :3
-Sorry if double post
Reply
#8

There you go, I have fixed it.
Reply
#9

ok i might sleep now its 10 Pm here i will test it today or tommorow i know you ahve send funds to me i will send the money just wait
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)