SetPlayerSkillLevel not loading.
#1

Hellou there.
I got tired of crying so i`m here hehe. Joke. I hav problem with setplayerskilllevel. I editel Ladmin4v2 to save skill level in user file. everything works. one kill with weapon [sawnoff for example] give you +1 skill point. but problem is when player spawns i can put 999 or whatever number i want and it gives me sawnoff one handed like its not loading. Probably you dont understand me but thats how i can explain. I will try better way to explain later. deal?
So.. there is the code. pieco of code.
In the start of script. Dont know it you need this but i will put there everything that i edited so you can figure out whats the problem becouse i have no idea.
Код:
enum PlayerData
{
	Registered,
	LoggedIn,
	Level,
	Muted,
	Caps,
	Jailed,
	JailTime,
	Frozen,
	FreezeTime,
	Kills,
	Deaths,
	Sawnoffskill,
	hours,
	mins,
	secs,
	TotalTime,
	ConnectTime,
 	MuteWarnings,
	Warnings,
	Spawned,
	TimesSpawned,
	God,
	GodCar,
	DoorsLocked,
	SpamCount,
	SpamTime,
	PingCount,
	PingTime,
	BotPing,
	pPing[PING_MAX_EXCEEDS],
	blip,
	blipS,
	pColour,
	pCar,
	SpecID,
	SpecType,
	bool:AllowedIn,
	FailLogin,
};
In the middle after that stuff
Код:
public OnPlayerConnect(playerid)
{
	PlayerInfo[playerid][Deaths] = 0;
	PlayerInfo[playerid][Kills] = 0;
	PlayerInfo[playerid][Sawnoffskill] = 0;
	PlayerInfo[playerid][Jailed] = 0;
	PlayerInfo[playerid][Frozen] = 0;
	PlayerInfo[playerid][Level] = 0;
	PlayerInfo[playerid][LoggedIn] = 0;
	PlayerInfo[playerid][Registered] = 0;
	PlayerInfo[playerid][TimesSpawned] = 0;
	PlayerInfo[playerid][Muted] = 0;
	PlayerInfo[playerid][MuteWarnings] = 0;
	PlayerInfo[playerid][Warnings] = 0;
	PlayerInfo[playerid][Caps] = 0;
	PlayerInfo[playerid][DoorsLocked] = 0;
	PlayerInfo[playerid][pCar] = -1;
	for(new i; i<PING_MAX_EXCEEDS; i++) PlayerInfo[playerid][pPing][i] = 0;
	PlayerInfo[playerid][SpamCount] = 0;
	PlayerInfo[playerid][SpamTime] = 0;
	PlayerInfo[playerid][PingCount] = 0;
	PlayerInfo[playerid][PingTime] = 0;
	PlayerInfo[playerid][FailLogin] = 0;
	PlayerInfo[playerid][ConnectTime] = gettime();
On playerspawn. I will not put whole code becouse that will be too much.
Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, PlayerInfo[playerid][Sawnoffskill]);
And there on playerdeath
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	if(GetPlayerWeapon(killerid) == 26)
    PlayerInfo[killerid][Sawnoffskill]++;
	SetPlayerSkillLevel(killerid, WEAPONSKILL_SAWNOFF_SHOTGUN, PlayerInfo[playerid][Sawnoffskill]);

	#if defined USE_STATS
    PlayerInfo[playerid][Deaths]++;
	#endif
    
	if(IsPlayerConnected(killerid) && killerid != INVALID_PLAYER_ID)	{
		#if defined USE_STATS
		PlayerInfo[killerid][Kills]++;
	    #endif
	}

	#if defined ENABLE_SPEC
	for(new x=0; x<MAX_PLAYERS; x++)
	    if(GetPlayerState(x) == PLAYER_STATE_SPECTATING && PlayerInfo[x][SpecID] == playerid)
	       AdvanceSpectate(x);
	#endif
	

	return 1;
}
This on register command
Код:
dcmd_register(playerid,params[])
{
    new dialogstr[256];
    new pame[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pame, sizeof(pame));
    if(!udb_Exists(PlayerName2(playerid))) format(dialogstr,sizeof(dialogstr),"{FFFFFF}Lietotajvards{00FF00} `%s` {FFFFFF}nav registrets, lai registretos ievadiet paroli!", pame), ShowPlayerDialog(playerid, registerdialog, DIALOG_STYLE_INPUT, "{FF0000}Registracija.", dialogstr, "Labi", "Atcelt");
    if (PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,red,"Jus jau esat registrejies un piesledzies.");
    if (udb_Exists(PlayerName2(playerid))) return SendClientMessage(playerid,red,"Sis akaunts jau eksiste, ludzu izmantojiet '/login'.");
    if (strlen(params) == 0) return SendClientMessage(playerid,red,"Pareiza izmantosana: '/register'");
    if (strlen(params) < 4 || strlen(params) > 20) return SendClientMessage(playerid,red,"Paroles garumam jabut lielakam par 3 burtiem/cipariem.");
    if (udb_Create(PlayerName2(playerid),params))
	{

    	new file[256],name[MAX_PLAYER_NAME], tmp3[100];
    	new strdate[20], year,month,day;	getdate(year, month, day);
		GetPlayerName(playerid,name,sizeof(name)); format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(name));
     	GetPlayerIp(playerid,tmp3,100);	dini_Set(file,"ip",tmp3);
//    	dini_Set(file,"password",params);
	    dUserSetINT(PlayerName2(playerid)).("registered",1);
   		format(strdate, sizeof(strdate), "%d/%d/%d",day,month,year);
		dini_Set(file,"RegisteredDate",strdate);
		dUserSetINT(PlayerName2(playerid)).("loggedin",1);
		dUserSetINT(PlayerName2(playerid)).("banned",0);
		dUserSetINT(PlayerName2(playerid)).("level",0);
	    dUserSetINT(PlayerName2(playerid)).("LastOn",0);
    	dUserSetINT(PlayerName2(playerid)).("money",0);
    	dUserSetINT(PlayerName2(playerid)).("kills",0);
	   	dUserSetINT(PlayerName2(playerid)).("deaths",0);
	   	dUserSetINT(PlayerName2(playerid)).("sawnoffskill",0);
	   	dUserSetINT(PlayerName2(playerid)).("hours",0);
	   	dUserSetINT(PlayerName2(playerid)).("minutes",0);
	   	dUserSetINT(PlayerName2(playerid)).("seconds",0);
	    PlayerInfo[playerid][LoggedIn] = 1;
	    PlayerInfo[playerid][Registered] = 1;
	    SendClientMessage(playerid, green, "Jus tikat registrets un automatiski pievienots.");
		PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
		return 1;
	}
    return 1;
}
and login player
Код:
LoginPlayer(playerid)
{
	if(ServerInfo[GiveMoney] == 1) {ResetPlayerMoney(playerid); GivePlayerMoney(playerid, dUserINT(PlayerName2(playerid)).("money") ); }
	dUserSetINT(PlayerName2(playerid)).("loggedin",1);
	PlayerInfo[playerid][Deaths] = (dUserINT(PlayerName2(playerid)).("deaths"));
	PlayerInfo[playerid][Kills] = (dUserINT(PlayerName2(playerid)).("kills"));
	PlayerInfo[playerid][Sawnoffskill] = (dUserINT(PlayerName2(playerid)).("sawnoffskill"));
 	PlayerInfo[playerid][Level] = (dUserINT(PlayerName2(playerid)).("level"));
   	PlayerInfo[playerid][hours] = dUserINT(PlayerName2(playerid)).("hours");
   	PlayerInfo[playerid][mins] = dUserINT(PlayerName2(playerid)).("minutes");
   	PlayerInfo[playerid][secs] = dUserINT(PlayerName2(playerid)).("seconds");
	PlayerInfo[playerid][Registered] = 1;
 	PlayerInfo[playerid][LoggedIn] = 1;
}
Player saving
Код:
SavePlayer(playerid)
{
   	dUserSetINT(PlayerName2(playerid)).("money",GetPlayerMoney(playerid));
   	dUserSetINT(PlayerName2(playerid)).("kills",PlayerInfo[playerid][Kills]);
   	dUserSetINT(PlayerName2(playerid)).("deaths",PlayerInfo[playerid][Deaths]);
   	dUserSetINT(PlayerName2(playerid)).("sawnoffskill", PlayerInfo[playerid][Sawnoffskill]);
   	
	new h, m, s;
    TotalGameTime(playerid, h, m, s);

	dUserSetINT(PlayerName2(playerid)).("hours", h);
	dUserSetINT(PlayerName2(playerid)).("minutes", m);
	dUserSetINT(PlayerName2(playerid)).("seconds", s);

   	new Float:x,Float:y,Float:z, interior;
   	GetPlayerPos(playerid,x,y,z);	interior = GetPlayerInterior(playerid);
    dUserSetINT(PlayerName2(playerid)).("x1",floatround(x));
	dUserSetINT(PlayerName2(playerid)).("y1",floatround(y));
	dUserSetINT(PlayerName2(playerid)).("z1",floatround(z));
    dUserSetINT(PlayerName2(playerid)).("interior1",interior);

	new weap1, ammo1, weap2, ammo2, weap3, ammo3, weap4, ammo4, weap5, ammo5, weap6, ammo6;
	GetPlayerWeaponData(playerid,2,weap1,ammo1);// hand gun
	GetPlayerWeaponData(playerid,3,weap2,ammo2);//shotgun
	GetPlayerWeaponData(playerid,4,weap3,ammo3);// SMG
	GetPlayerWeaponData(playerid,5,weap4,ammo4);// AK47 / M4
	GetPlayerWeaponData(playerid,6,weap5,ammo5);// rifle
	GetPlayerWeaponData(playerid,7,weap6,ammo6);// rocket launcher
   	dUserSetINT(PlayerName2(playerid)).("weap1",weap1); dUserSetINT(PlayerName2(playerid)).("weap1ammo",ammo1);
  	dUserSetINT(PlayerName2(playerid)).("weap2",weap2);	dUserSetINT(PlayerName2(playerid)).("weap2ammo",ammo2);
  	dUserSetINT(PlayerName2(playerid)).("weap3",weap3);	dUserSetINT(PlayerName2(playerid)).("weap3ammo",ammo3);
	dUserSetINT(PlayerName2(playerid)).("weap4",weap4); dUserSetINT(PlayerName2(playerid)).("weap4ammo",ammo4);
  	dUserSetINT(PlayerName2(playerid)).("weap5",weap5);	dUserSetINT(PlayerName2(playerid)).("weap5ammo",ammo5);
	dUserSetINT(PlayerName2(playerid)).("weap6",weap6); dUserSetINT(PlayerName2(playerid)).("weap6ammo",ammo6);

	new	Float:health;	GetPlayerHealth(playerid, Float:health);
	new	Float:armour;	GetPlayerArmour(playerid, Float:armour);
	new year,month,day;	getdate(year, month, day);
	new strdate[20];	format(strdate, sizeof(strdate), "%d.%d.%d",day,month,year);
	new file[256]; 		format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(PlayerName2(playerid)) );

	dUserSetINT(PlayerName2(playerid)).("health",floatround(health));
    dUserSetINT(PlayerName2(playerid)).("armour",floatround(armour));
	dini_Set(file,"LastOn",strdate);
	dUserSetINT(PlayerName2(playerid)).("loggedin",0);
	dUserSetINT(PlayerName2(playerid)).("TimesOnServer",(dUserINT(PlayerName2(playerid)).("TimesOnServer"))+1);
}
I hope this is not too much in a post. if it is sorry.
And yes i think the problem is in onplayerspawns but i dont know if it is.. Yes and its compiles without errors or warnings.
Reply
#2

Debug it with print.
Reply
#3

Heh. I`m njuub in this stuff so i dont know how to do that. And i dont know what it is what is debug you`re talking about. If you can give me a link where i can learn about that stuff or give me a tip i will be grateful.
Reply
#4

Huge sorry for double posting but i did it by my self. a bit proud right now. If someone interested what was wrong

OnPlayerSpawn
Код:
	SetPlayerSkillLevel(playerid, WEAPONSKILL_SAWNOFF_SHOTGUN, (dUserINT(PlayerName2(playerid)).("sawnoffskill")) );
Thanks and Goodbye!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)