SA-MP Forums Archive
SetPlayerSkill! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SetPlayerSkill! (/showthread.php?tid=276872)

Pages: 1 2


SetPlayerSkill! - samtey - 15.08.2011

Hi!

I am using INI to save my datas! Now, I want to do something like:

A player skill is set by 0 and increases lik in single player!

Under OnPlayerSpawn now:

SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, 1);

and all other weapons!

Now, how to save that skills from every weapon

And each 10 points it will say: Your weaponlevel on weapon X has increased by 10!


Re: SetPlayerSkill! - Darnell - 15.08.2011

I don't think that it's available in SAMP, yet.
Try making /train and make them frozen for 10 seconds in the ammunation, and increase their weaponskill.


AW: SetPlayerSkill! - samtey - 15.08.2011

It is available, I only dunno how to save the weapon skill!


Re: SetPlayerSkill! - Darnell - 15.08.2011

dini.


Re: SetPlayerSkill! - playbox12 - 15.08.2011

As far as I know there is no GetPlayerSkillLevel, so what I would do is create a variable that'll keep the skill level for example.

pawn Код:
new SAWNOFF_SKILL[MAX_PLAYERS]; //(don't use this, implement it how you want it).

public OnPlayerConnect(playerid)
{
    //load the skill variable and store it inside 'SAWNOFF_SKILL[playerid]'
}

//then if you want to increase his skill level by one you simply do;

SAWNOFF_SKILL[playerid]++;
SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, SAWNOFF_SKILL[playerid]);

//if you want to decrease his skill level you do;

SAWNOFF_SKILL[playerid]--;
SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, SAWNOFF_SKILL[playerid]);

//when you want to save it you just store SAWNOFF_SKILL[playerid] in the players file
You can use any saving include (or plugin) like y_ini, mysql, sqlite


AW: SetPlayerSkill! - samtey - 15.08.2011

Hi!

I do not really understand you, what to do under OnPlayerConnect?

Also, I want that his Skilllevel increases +1 after every 5 minutes(if he is using it)


Re: AW: SetPlayerSkill! - Libra_PL - 15.08.2011

Quote:
Originally Posted by samtey
Посмотреть сообщение
Hi!

I do not really understand you, what to do under OnPlayerConnect?

Also, I want that his Skilllevel increases +1 after every 5 minutes(if he is using it)
1. In OnPlayerConnect load player's skill level from file.
2. Hmm, create a timer?


AW: SetPlayerSkill! - samtey - 15.08.2011

1. How?
2. YES!
3. You will get REP!


Re: SetPlayerSkill! - Libra_PL - 15.08.2011

Oh, and you don't know how to make a timer? This is an example for sawnoff shotgun...

Up the script:
Код:
new SawnoffShotgunSkill[MAX_PLAYERS];
In OnGameModeInIt:
Код:
SetTimer("OnSkillLevelUpdate",300000,1); //300k - it's 5 minutes
In OnPlayerConnect:
Код:
public OnPlayerConnect(playerid)
{
	SawnoffShotgunSkill[playerid] = 0; //To clear skill level when new player connects

	//Load skill from file
	new PlayerFile[64];
	format(PlayerFile, sizeof(PlayerFile),"%s.ini",GetName(playerid));
	if(dini_Exists(PlayerFile))
	{
		SawnoffShotgunSkill[playerid] = dini_Int(PlayerFile, "SawnoffShotgun");
	}
	return 1;
}
//Under the script (somewhere)
Код:
forward OnSkillLevelUpdate();
public OnSkillLevelUpdate()
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
			SawnoffShotgunSkill[i]+=5; //Increase skill by 5 points
			SetPlayerSkillLevel(playerid,WEAPONSKILL_SAWNOFF_SHOTGUN,SawnoffShotgunSkill[i]);

			//Now save skill to file
			new PlayerFile[64];
			format(PlayerFile, sizeof(PlayerFile),"%s.ini",GetName(i));
			if(!dini_Exists(PlayerFile))
			{
				dini_Create(PlayerFile);
			}

			dini_IntSet(PlayerFile, "SawnoffShotgun", SawnoffShotgunSkill[i]);
		}
	}
	return 1;
}
Stock for GetName that I always use:
Код:
stock GetName(playerid)
{
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, sizeof(name));
	return name;
}
Untested. Should work, if you have any errors - tell me (or if you can fix them)... BTW, it's made with dini.


AW: SetPlayerSkill! - samtey - 15.08.2011

Wow, ty!

But how to save it into INI?


Re: SetPlayerSkill! - Flo_White - 15.08.2011

at OnplayerDisconnect
pawn Код:
new PlayerFile[64];
format(PlayerFile, sizeof(PlayerFile),"%s.ini",GetName(i));
if(dini_Exists(PlayerFile))
{
    dini_IntSet(PlayerFile, "SawnoffShotgun",SawnoffShotgunSkill[playerid]);
}



AW: SetPlayerSkill! - samtey - 15.08.2011

Omg, I also got those:

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[]) {
        switch(
dialogid) {
            case 
DIALOG_REGISTER: {
                if(!
response) return Kick(playerid);
                if(
response) {
                    if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT""WHITE"Registering...",""RED"You have entered an invalid password.\n"WHITE"Type your password below to register a new account.","Register","Quit");
                    if(
INI_Open(getINI(playerid))) {
                        
INI_WriteString("Password",inputtext);
                        
INI_WriteInt("Cash"0);
                        
INI_WriteInt("Admin"0);
                        
INI_WriteInt("FirstTime"0);
                        
INI_WriteInt("Skin"0);
                        
INI_WriteInt("Score"0);
                        
INI_Save();
                        
INI_Close();
                        
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""WHITE"Login",""WHITE"Type your password below to login.","Login","Quit");
                    }
                }
            } case 
DIALOG_LOGIN: {
                if(!
response) return Kick playerid );
                if(
response) {
                    if(!
strlen(inputtext)) return ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT""WHITE"Login",""RED"You have entered an invalid password.\n"WHITE"Type your password below to login.","Login","Quit");
                    if(
INI_Open(getINI(playerid))) {
                        
INI_ReadString(PlayerInfo[playerid][pPass],"Password",20);
                        if(
strcmp(inputtext,PlayerInfo[playerid][pPass],false)) {
                            
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT""WHITE"Login",""RED"You have entered an incorrect password.\n"WHITE"Type your password below to login.","Login","Quit");
                        }
                        
GivePlayerMoneyplayeridINI_ReadInt"Cash" ) );
                        
PlayerInfo[playerid][pAdmin] = INI_ReadInt("Admin");
                        
gFirstTimeHasJoined[playerid] = INI_ReadInt("FirstTime");
                        
gPlayerSkinForEver[playerid] = INI_ReadInt("Skin");
                        
SetPlayerScoreplayeridINI_ReadInt"Score" ) );
                        
INI_Close();
                    }
                }
            }
        }
        return 
1;
    } 



Re: SetPlayerSkill! - Darnell - 15.08.2011

Add under the score;
PHP код:
                        INI_WriteInt("Score"0); 
This :
pawn Код:
INI_WriteInt("SawnOffSkill", 0);
And just continue with the weapons.
After that, add under the score loading thingy;
pawn Код:
SetPlayerScore( playerid, INI_ReadInt( "Score" ) );
This:
pawn Код:
SetPlayerSkillLevel(playerid, INI_ReadInt("SawnOffSkill"));
And continue with other weapons.


AW: SetPlayerSkill! - samtey - 15.08.2011

Код:
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(604) : error 017: undefined symbol "dini_Exists"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(606) : error 017: undefined symbol "dini_Int"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(621) : error 017: undefined symbol "i"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(622) : error 017: undefined symbol "dini_Exists"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(624) : error 017: undefined symbol "dini_IntSet"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(936) : warning 202: number of arguments does not match definition
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(982) : error 017: undefined symbol "playerid"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(987) : error 017: undefined symbol "dini_Exists"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(989) : error 017: undefined symbol "dini_Create"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(992) : error 017: undefined symbol "dini_IntSet"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


9 Errors.
Hell, I don't use DINI, I USE INI!!! Anybody fix them please?

PHP код:
new PlayerFile[64];
        
format(PlayerFilesizeof(PlayerFile),"%s.ini",GetName(playerid));
        if(
dini_Exists(PlayerFile))
        {
        
SawnoffShotgunSkill[playerid] = dini_Int(PlayerFile"SawnoffShotgun");
        }
        
        
GetPlayerName(playeridgPlayerName[playerid], MAX_PLAYER_NAME);
        if(
fexist(getINI(playerid))) ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""RED"This nickname is registered!",""WHITE"Type your password below to login.","Login","Quit");
        else 
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT,""RED"Hi! You are new here, you have to register your account!",""WHITE"Type your password below to register a new account.","Register","Quit");
        
        return 
1;
    }
    public 
OnPlayerDisconnect(playeridreason) {
        new 
PlayerFile[64];
        
format(PlayerFilesizeof(PlayerFile),"%s.ini",GetName(i));
        if(
dini_Exists(PlayerFile))
        {
            
dini_IntSet(PlayerFile"SawnoffShotgun",SawnoffShotgunSkill[playerid]);
        } 
PHP код:
forward OnSkillLevelUpdate();
public 
OnSkillLevelUpdate()
{
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            
SawnoffShotgunSkill[i]+=5//Increase skill by 5 points
            
SetPlayerSkillLevel(playerid,WEAPONSKILL_SAWNOFF_SHOTGUN,SawnoffShotgunSkill[i]);
            
//Now save skill to file
            
new PlayerFile[64];
            
format(PlayerFilesizeof(PlayerFile),"%s.ini",GetName(i));
            if(!
dini_Exists(PlayerFile))
            {
                
dini_Create(PlayerFile);
            }
            
dini_IntSet(PlayerFile"SawnoffShotgun"SawnoffShotgunSkill[i]);
        }
    }
    return 
1;




Re: AW: SetPlayerSkill! - Kush - 15.08.2011

Quote:
Originally Posted by samtey
Посмотреть сообщение
Код:
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(604) : error 017: undefined symbol "dini_Exists"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(606) : error 017: undefined symbol "dini_Int"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(621) : error 017: undefined symbol "i"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(622) : error 017: undefined symbol "dini_Exists"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(624) : error 017: undefined symbol "dini_IntSet"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(936) : warning 202: number of arguments does not match definition
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(982) : error 017: undefined symbol "playerid"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(987) : error 017: undefined symbol "dini_Exists"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(989) : error 017: undefined symbol "dini_Create"
D:\Program Files\Rockstar Games\GTA San Andreas\eigener SAMP\gamemodes\deathmatch.pwn(992) : error 017: undefined symbol "dini_IntSet"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


9 Errors.
Hell, I don't use DINI, I USE INI!!! Anybody fix them please?

PHP код:
new PlayerFile[64];
        
format(PlayerFilesizeof(PlayerFile),"%s.ini",GetName(playerid));
        if(
dini_Exists(PlayerFile))
        {
        
SawnoffShotgunSkill[playerid] = dini_Int(PlayerFile"SawnoffShotgun");
        }
        
        
GetPlayerName(playeridgPlayerName[playerid], MAX_PLAYER_NAME);
        if(
fexist(getINI(playerid))) ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_INPUT,""RED"This nickname is registered!",""WHITE"Type your password below to login.","Login","Quit");
        else 
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT,""RED"Hi! You are new here, you have to register your account!",""WHITE"Type your password below to register a new account.","Register","Quit");
        
        return 
1;
    }
    public 
OnPlayerDisconnect(playeridreason) {
        new 
PlayerFile[64];
        
format(PlayerFilesizeof(PlayerFile),"%s.ini",GetName(i));
        if(
dini_Exists(PlayerFile))
        {
            
dini_IntSet(PlayerFile"SawnoffShotgun",SawnoffShotgunSkill[playerid]);
        } 
PHP код:
forward OnSkillLevelUpdate();
public 
OnSkillLevelUpdate()
{
    for(new 
0MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            
SawnoffShotgunSkill[i]+=5//Increase skill by 5 points
            
SetPlayerSkillLevel(playerid,WEAPONSKILL_SAWNOFF_SHOTGUN,SawnoffShotgunSkill[i]);
            
//Now save skill to file
            
new PlayerFile[64];
            
format(PlayerFilesizeof(PlayerFile),"%s.ini",GetName(i));
            if(!
dini_Exists(PlayerFile))
            {
                
dini_Create(PlayerFile);
            }
            
dini_IntSet(PlayerFile"SawnoffShotgun"SawnoffShotgunSkill[i]);
        }
    }
    return 
1;

Samtey, your attempting to basically call both .INI based systems (both SII and dini). I understood nothing of what is going on. What would you liked saved?


AW: SetPlayerSkill! - samtey - 15.08.2011

Omg, why didn't u understand? Everybody did!

I want:

Every player has from beginning every weapon skill by 0!

It will increase +1 EVERY 5 minutes he is using it! (only if he is using!)

And the skill willl get saved in INI!


Re: AW: SetPlayerSkill! - Markx - 15.08.2011

Quote:
Originally Posted by samtey
Посмотреть сообщение
Omg, why didn't u understand? Everybody did!

I want:

Every player has from beginning every weapon skill by 0!

It will increase +1 EVERY 5 minutes he is using it! (only if he is using!)

And the skill willl get saved in INI!
Why the hell you got dini in the gamemode then!?


AW: SetPlayerSkill! - samtey - 15.08.2011

I haven't! A user on the first page gave a dini code to me! I dunno why I took it...


Re: AW: SetPlayerSkill! - Kush - 15.08.2011

Quote:
Originally Posted by samtey
Посмотреть сообщение
Omg, why didn't u understand? Everybody did!

I want:

Every player has from beginning every weapon skill by 0!

It will increase +1 EVERY 5 minutes he is using it! (only if he is using!)

And the skill willl get saved in INI!
Alright, Set the player's weapon skill upon spawn. If the player has the weapon, create a simple timer to check the amount of time he has the weapon, and after 5 minutes set his weapon skill.

Sounds good?


AW: SetPlayerSkill! - samtey - 15.08.2011

Yeah! Under OnPlayerSpawn:

PHP код:
SetPlayerSkillLevel(playeridWEAPONSKILL_SAWNOFF_SHOTGUN0); //and others 
Rest:

PHP код:
SetTimer("OnSkillLevelUpdate",300000,1); 
I only dunno how to check if he HAS the weapon and how to save things into INI^^