Need help with GVar and PVar
#1

Hellu,
I have gamemode and filterscript. I don't know why PVar is not saving Mission Passed data. have a look on the codes.

This is the gamemode where i SetPVar:
Code:
enum PlayerData
{
	MissionPass
};
new AccInfo[MAX_PLAYERS][PlayerData];

public OnPlayerConnect(playerid)
{
        AccInfo[playerid][MissionPass] 	= 0;
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    AccInfo[playerid][MissionPass] = 0;
	return 1;
}

forward NoExplode(playerid);
public NoExplode(playerid)
{
	for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
    			PlayerPlaySound(playerid, 1185, 0.0, 0.0, 0.0);
        	    if(gTeam[i] == TEAM_ATTACKERS)
        	    {
        	        GameTextForPlayer(i, "~g~ Mission Completed", 6000, 4);
        	        GivePlayerMoney(i, 4000);
   	        	    SetPlayerScore(i,GetPlayerScore(i)+5);
   	        	    AccInfo[playerid][MissionPass]++;
   	        	    SetPVarInt(playerid, "MissionPass", AccInfo[playerid][MissionPass]); //PVar  is here
					SendClientMessage(playerid,-1,"{7C7C7C}» You've Recieved 5 Points and $4,000 for Completing the mission Objective.");
        	    }
        	    if(gTeam[i] == TEAM_DEFENDERS)
        	    {
        	        GameTextForPlayer(i, "~r~ Mission Failed", 6000, 4);
					GivePlayerMoney(i, -2000);
					SendClientMessage(playerid,-1,"{FF0000}» You've Lost -$2000 Money for Not completing the Mission Objective.");
        	    }
    SetTimer("NewMode",5000,false);
}
}
	return 1;
}
& This is the filterscript where i Set GetPVar:
Code:
	if(strcmp(cmd, "/stats", true) == 0)
	{
		new string[128];
		new pDeaths;
		new player1, h, m, s;
		new file[100];
		new str[256];

		if(!strlen(params)) player1 = playerid;
		else player1 = strval(params);

		if(IsPlayerConnected(player1))
		{

		#if USE_DIALOGS == true

		new dialog[1000];
		format(file,sizeof(file),"/eAdmin/Accounts/%s.sav",udb_encode(PlayerName2(player1)));
	    TotalGameTime(player1, h, m, s);
		if(AccInfo[player1][Deaths] == 0) pDeaths = 1;
		else pDeaths = AccInfo[player1][Deaths];
		format(string, sizeof(string), "{00FF00}» AccServ: {FFFFFF}You're Currently viewing the Stats of %s (/stats {PlayerID])",PlayerName2(player1));
		SendClientMessage(playerid, green, string);
		PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
		format(string, sizeof(string),"{72A6FF}Mission Passed: {FFFFFF}%d\n",GetPVarInt(playerid, "MissionPass")); //GVar
		strcat(dialog,string);
		return ShowPlayerDialog(playerid, 1234, DIALOG_STYLE_MSGBOX,"{FFFF00}eX-MM - {FFFFFF}Player's Statistics",dialog,"Close","");
		} else
		return SendClientMessage(playerid, red, "{FF0000}» Error: {BABABA}Player Not Connected.");
	}

//from here the player data load when they login
LoginPlayer(playerid)
{
	if(ServerInfo[GiveMoney] == 1)
	{
	ResetPlayerMoney(playerid);
	GivePlayerMoney(playerid, dUserINT(PlayerName2(playerid)).("Money"));
	}
	SetPlayerWantedLevel(playerid,dUserINT(PlayerName2(playerid)).("WantedLevel"));
	#if SaveScore == true
	SetPlayerScore(playerid,dUserINT(PlayerName2(playerid)).("Score"));
	#endif
	dUserSetINT(PlayerName2(playerid)).("Loggedin",1);
	AccInfo[playerid][Deaths] 		= (dUserINT(PlayerName2(playerid)).("Deaths"));
	AccInfo[playerid][Kills] 		= (dUserINT(PlayerName2(playerid)).("Kills"));
 	AccInfo[playerid][Level] 		= (dUserINT(PlayerName2(playerid)).("Level"));
 	AccInfo[playerid][pVip] 		= (dUserINT(PlayerName2(playerid)).("AccountType"));
   	AccInfo[playerid][hours]		= dUserINT(PlayerName2(playerid)).("Hours");
   	AccInfo[playerid][mins] 		= dUserINT(PlayerName2(playerid)).("Minutes");
   	AccInfo[playerid][secs] 		= dUserINT(PlayerName2(playerid)).("Seconds");
   	AccInfo[playerid][Reactionwon]  = (dUserINT(PlayerName2(playerid)).("Reactionwon"));
	AccInfo[playerid][Registered]	= 1;
 	AccInfo[playerid][LoggedIn] 	= 1;
       GetPVarInt(playerid, "MissionPass"); //GVar
 	
}

//Here player data save
SavePlayerStats(playerid)
{
   	dUserSetINT(PlayerName2(playerid)).("Money",GetPlayerMoney(playerid));
   	dUserSetINT(PlayerName2(playerid)).("Kills",AccInfo[playerid][Kills]);
   	dUserSetINT(PlayerName2(playerid)).("Reactionwon",AccInfo[playerid][Reactionwon]);
   	dUserSetINT(PlayerName2(playerid)).("Deaths",AccInfo[playerid][Deaths]);
        dUserSetINT(PlayerName2(playerid)).("WantedLevel",GetPlayerWantedLevel(playerid));
	GetPVarInt(playerid, "MissionPass");
}
Sorry i know i have mistaken somewhere lel
Reply
#2

anyone? please
Reply
#3

BUMP.
Reply
#4

Try to check if its value = 0, which means it wasn't set,
And where do you use "NoExplode", You might be setting it after trying to get it,
also try to check what does it return.
Reply
#5

i didn't got you, you mean like this?

Code:
SetPVarInt(playerid, "MissionPass", AccInfo[playerid][MissionPass] =0);
Reply
#6

Okay you've got two thing to check for, when you set it make sure it's actually set, and when you load it make sure it's probably loaded, try to come up with a number and set it, then check if it returns that number after you set it, then save and load and check it again,

Quote:
Originally Posted by SpikY_
View Post
i didn't got you, you mean like this?

Code:
SetPVarInt(playerid, "MissionPass", AccInfo[playerid][MissionPass] =0);
No, use
pawn Code:
if(GetPVarInt(playerid, "MissionPass") != 0) print("yay");
or
pawn Code:
if(GetPVarInt(playerid, "MissionPass") == random number) print("yay");
tell me if you need an example
Reply
#7

Sorry gone inactive.

OT: Where should i add this ?
Code:
if(GetPVarInt(playerid, "MissionPass") == random number) print("yay");
I'm confused with GVar & PVar
Reply
#8

Why do you get the PVar when you login a player, you should set it, when the player disconnects you save it, when a player logs in you load it and set it again ?..

Use this to know the current value it has.

pawn Code:
forward NoExplode(playerid);
public NoExplode(playerid)
{
    for(new i; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i))
    {
        PlayerPlaySound(playerid, 1185, 0.0, 0.0, 0.0);
        if(gTeam[i] == TEAM_ATTACKERS)
        {
            GameTextForPlayer(i, "~g~ Mission Completed", 6000, 4);
            GivePlayerMoney(i, 4000);
            SetPlayerScore(i,GetPlayerScore(i)+5);
            AccInfo[playerid][MissionPass]++;
            SetPVarInt(playerid, "MissionPass", AccInfo[playerid][MissionPass]); //PVar  is here
            SendClientMessage(playerid,-1,"{7C7C7C}» You've Recieved 5 Points and $4,000 for Completing the mission Objective.");
           
            new str[128]; format(str, 128, "PVar/MissionPass: %d", GetPVarInt(playerid, "MissionPass"));
            SendClientMessage(playerid, -1, str);
        }
        if(gTeam[i] == TEAM_DEFENDERS)
        {
            GameTextForPlayer(i, "~r~ Mission Failed", 6000, 4);
            GivePlayerMoney(i, -2000);
            SendClientMessage(playerid,-1,"{FF0000}» You've Lost -$2000 Money for Not completing the Mission Objective.");
        }
        SetTimer("NewMode",5000,false);
    }
    return 1;
]
Reply
#9

when i passed the mission i got
" PVar/MissionPass: 1 " client message. and yeah First i use SetPVar on player login but it was giving me error.

Code:
 Undefineded Symbol "MissionPass"
Reply
#10

Anyone please?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)