SA-MP Forums Archive
[HELP Please] funmode on/off - 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: [HELP Please] funmode on/off (/showthread.php?tid=260197)



[HELP Please] funmode on/off - lionlev - 07.06.2011

Hello, once again, I've got a problem..
Could you help me?
Well, I wrote a small filterscript that allows you to fly and autorepair by writing command "/funmodeon"
and "/funmodeoff" that turns it off. But when I turning it off, the autofix is still running for some reason..
Can you help me to fix it please?
Here is the code:
Код:
#include <a_samp>
#define FILTERSCRIPT
forward AutoR();
new flying;
#define PRESSED(%0) \
	(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print("Auto Repair loaded");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    flying = 0;
	new autofix;
	if(strcmp(cmdtext, "/funmodeon", true) == 0) {
 		autofix = SetTimer("AutoR", 1000, 1);
 		flying = 1;
        GameTextForAll("~g~Auto Fix is Enabled", 5000, 3);
	}
	if(strcmp(cmdtext, "/funmodeoff", true) == 0) {
 		KillTimer(autofix);
 		flying = 0;
  		GameTextForAll("~r~Auto Fix is disabled. ]Kill Time!]", 5000, 3);
	}
}
public AutoR() {
    for(new playerid=0; playerid<MAX_PLAYERS; playerid++) {
	    if(IsPlayerConnected(playerid)) {
			new Float:health, cid;
			if (IsPlayerInAnyVehicle(playerid)) {
  				cid = GetPlayerVehicleID(playerid);
				GetVehicleHealth(cid, health);
				if (health < 999) {
					RepairVehicle(cid);
					SetVehicleHealth(cid,1000);
				}
			}
		}
	}
	return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if (flying == 1)
	{
	//fly h button
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
		if (PRESSED(KEY_CROUCH))
		{
        	new Float:x, Float:y, Float:z;
			GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
			SetVehicleVelocity(GetPlayerVehicleID(playerid) ,x ,y ,z+0.3);
		}
	}
	}
	return 1;
}



Re: [HELP Please] funmode on/off - lionlev - 08.06.2011

No one will help me out?


Re: [HELP Please] funmode on/off - StilThere - 08.06.2011

I think you should define new autofix globally, so outside of OnPlayerCommandText, like this
pawn Код:
#include <a_samp>
#define FILTERSCRIPT
forward AutoR();
new flying;
new autofix;

// ... rest of code



Re: [HELP Please] funmode on/off - lionlev - 08.06.2011

Quote:
Originally Posted by StilThere
Посмотреть сообщение
I think you should define new autofix globally, so outside of OnPlayerCommandText, like this
pawn Код:
#include <a_samp>
#define FILTERSCRIPT
forward AutoR();
new flying;
new autofix;

// ... rest of code
Thanks! Worked!


Re: [HELP Please] funmode on/off - StilThere - 08.06.2011

Lovely