SA-MP Forums Archive
Is there is any easy way? - 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)
+--- Thread: Is there is any easy way? (/showthread.php?tid=587416)



Is there is any easy way? - SpikY_ - 30.08.2015

Is there is any easy way of using gamemode variables in my filterscript?
I have created GVars in my gamemode and filterscript but the problem is onPlayerDisconnect, the vars gets deleted. I've done many things to fix it but i can't.

So is there is any better way of using vars of gamemode in filterscript?


Re: Is there is any easy way? - Gazzy - 30.08.2015

I know of no other way to put gamemode variables in your filter script. I guess MySQL would kind of be a good way to use variables in your filterscript, but apart from that there's no real easy way.


Re: Is there is any easy way? - SpikY_ - 30.08.2015

Quote:
Originally Posted by Gazzy
Посмотреть сообщение
I know of no other way to put gamemode variables in your filter script. I guess MySQL would kind of be a good way to use variables in your filterscript, but apart from that there's no real easy way.
it will take time to learn MySQL


Re: Is there is any easy way? - Gazzy - 30.08.2015

It's worth the time though


Re: Is there is any easy way? - IceBilizard - 30.08.2015

Or you can save them in a file using dini, Y_Ini or anything then get in filterscript using dini_Int, dini_Get etc..


Re: Is there is any easy way? - SpikY_ - 30.08.2015

So i tried dini.
but the Mission pass doesn't count. have a look on the co-ordinates.

Код:
#define   MissionPath	"MissionStats/%s.ini"

public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), MissionPath, name);
    if (!dini_Exists(file))
    {
    	dini_Create(file);
        dini_IntSet(file, "MissionPass", AccInfo[playerid][MissionPass] = 0);
    }
    if(fexist(file))
    {
        AccInfo[playerid][MissionPass] = dini_Int(file, "MissionPass");
    }
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{    
    SaveMissionStats(playerid);
	return 1;
}

stock SaveMissionStats(playerid)
{
    new name[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), MissionPath, name);

    dini_IntSet(file, "MissionPass",AccInfo[playerid][MissionPass]);
	return 1;
}

stock pName(playerid)
{
	new GetName[24];
	GetPlayerName(playerid, GetName, 24);
	return GetName;
}

forward NoExplode(playerid);
public NoExplode(playerid)
{
	for(new i; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i))
	{
		if(gTeam[i] == TEAM_ATTACKERS)
		{
			MissionPassed(i);
			GivePlayerMoney(i, 4000);
			SetPlayerScore(i,GetPlayerScore(i)+3);
			SendClientMessage(i,-1,"{7C7C7C}» You've Recieved 3 Points and $4,000 for Completing the mission Objective.");
			PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
   	      	

            AccInfo[playerid][MissionPass]++;
			
		}
		if(gTeam[i] == TEAM_DEFENDERS)
		{
			MissionFailed(i);
			PlayerPlaySound(i, 1085, 0.0, 0.0, 0.0);
			GivePlayerMoney(i, -2000);
			SendClientMessage(i,-1,"{FF0000}» You've Lost -$2000 Money for not completing the Mission Objective.");
		}
		SetTimerEx("NewMode",14000,false,"i", playerid);
	}
	return 1;
}
and there is a file i have created.

Код:
MissionStats > %s.ini
and when i copy the player file, its " MissionPass=0 "


Re: Is there is any easy way? - Abagail - 30.08.2015

You can use CallRemoteFunction to call a remote function that can do something, you can pass variables through this method:

pawn Код:
stock SetPlayerScoreEx(playerid, score)
{
      return CallRemoteFunction("_SetPlayerScore", "dd", playerid, score);
}
Then in the remote script:
pawn Код:
forward _SetPlayerScore(playerid, score);
public _SetPlayerScore(playerid, score)
{
      SetPlayerScore(playerid, score);
      // do whatever else
      return 1;
}



Re: Is there is any easy way? - SpikY_ - 01.09.2015

Quote:
Originally Posted by Abagail
Посмотреть сообщение
You can use CallRemoteFunction to call a remote function that can do something, you can pass variables through this method:

pawn Код:
stock SetPlayerScoreEx(playerid, score)
{
      return CallRemoteFunction("_SetPlayerScore", "dd", playerid, score);
}
Then in the remote script:
pawn Код:
forward _SetPlayerScore(playerid, score);
public _SetPlayerScore(playerid, score)
{
      SetPlayerScore(playerid, score);
      // do whatever else
      return 1;
}
Thanks! but i already tried this method, have a look on the codes:


THIS IS IN FILTERSCRIPT:
Код:
CMD:mstats(playerid, params[])
{
	new string[128];
	format(string, sizeof(string),"{72A6FF}Mission Passed: {FFFFFF}%d\n", CallRemoteFunction("MPass", "d", playerid));
	SendClientMessage(playerid,-1, string);
    return 1;
}
THIS IS IN GAMEMODE:
Код:
forward MPass(playerid);
public MPass(playerid)
{
   return AccInfo[playerid][MissionPass];
}
NOTE: when the mode changes it gets on "0"


Re: Is there is any easy way? - Abagail - 01.09.2015

I never said it would work properly with returns, I just suggested using it to communicate between the scripts which it does.

You can try using SVars or PVars to communicate values through the scripts. Or you can call another remote function carrying the values and then send a message to a player there.


Re: Is there is any easy way? - Logofero - 05.09.2015

Quote:
Originally Posted by SpikY_
Посмотреть сообщение
Thanks! but i already tried this method, have a look on the codes:


THIS IS IN FILTERSCRIPT:
Код:
CMD:mstats(playerid, params[])
{
	new string[128];
	format(string, sizeof(string),"{72A6FF}Mission Passed: {FFFFFF}%d\n", CallRemoteFunction("MPass", "d", playerid));
	SendClientMessage(playerid,-1, string);
    return 1;
}
THIS IS IN GAMEMODE:
Код:
forward MPass(playerid);
public MPass(playerid)
{
   return AccInfo[playerid][MissionPass];
}
NOTE: when the mode changes it gets on "0"
I get to call the functions of the gamemode > filterscript, but not conversely.

That maybe you can CallRemoteFunction only works call in gamemode events <-Ok-> filterscript
But call in filterscript <-/-> gamemode.