[FilterScript] Simple Speedboost system with command
#1

Код:
#include <a_samp>
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_GREEN 0x33AA33AA
//speedboost
new att[MAX_PLAYERS];
new Text:Textdraw0;
ON GAME MODE INIT
Код:
Textdraw0 = TextDrawCreate(127.000000, 417.000000, "SPEEDBOOST ENBLED");
TextDrawBackgroundColor(Textdraw0, 255);
TextDrawFont(Textdraw0, 1);
TextDrawLetterSize(Textdraw0, 0.390000, 1.200000);
TextDrawColor(Textdraw0, -16711681);
TextDrawSetOutline(Textdraw0, 1);
TextDrawSetProportional(Textdraw0, 0);
ON PLAYER CONNECT
Код:
att[playerid] = false;
TextDrawHideForPlayer(playerid,Textdraw0);
ON PLAYER COMMAND TEXT
Код:
if (strcmp(cmdtext,"/speed", true) == 0)
{
if(att[playerid])
		{
            if(!IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid,COLOR_ORANGE,"You aren't in a car.");
			att[playerid] = false;
			SendClientMessage(playerid, COLOR_GREEN, "You have disabled speedboost. Type /speed to enable it.");
			TextDrawHideForPlayer(playerid,Textdraw0);

		}
		else
		{
		    if(!IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid,COLOR_ORANGE,"You aren't in a car.");
			att[playerid] = true;
			SendClientMessage(playerid, COLOR_GREEN, "You have enabled speedbost. Type /speed to disable it.");
			TextDrawShowForPlayer(playerid,Textdraw0);
		}
return 1;
}
return 0;
}
ONPLAYER ENTER VEHICLE
Код:
if( att[playerid] == 1)
{
TextDrawShowForPlayer(playerid,Textdraw0);
SendClientMessage(playerid, COLOR_ORANGE, "Type /speed to enable or disable speedbost.");
}
SendClientMessage(playerid, COLOR_ORANGE, "Type /speed to enable or disable speedbost.");
return 1;
}
ONPLAYER EXIT VEHICLE
Код:
if( att[playerid] == 1)
{
TextDrawHideForPlayer(playerid,Textdraw0);
}
return 1;
}
OnPlayerKeyStateChange
Код:
if( att[playerid] == 0) return 0;

if(newkeys & KEY_FIRE && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
	if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
	new Float:x, Float:y, Float:z;
	GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
	SetVehicleVelocity(GetPlayerVehicleID(playerid), x * 3, y * 3, z * 3);
		}
    }
return 1;
}
sp.pwn
sp.amx
Reply
#2


you should put it all in one FS and post it here.
Reply
#3

Good job, but it can be better... Why you're checking player state and if he's in any vehicles twice?

P.S: Compile your script before post it...
Reply
#4

Okay, first off, good job, I can see you've spent a certain amount of time on this filterscript, but just to note:

1. Why you people just adore strcmp and strtok beats me, you should change it to zcmd or anything better than strcmp.

2. You don't need to hide the textdraw from the player when he connects, it doesn't even show up, so useless although harmless.

3. You do realise the textdraw will REMAIN shown untill he leaves the car right? it's intended appearently, create a timer to disable it (3 secs maybe) cause it gets so annoying

4. Compile this up and make it into a filterscript.


Overall, not a bad job, a bit loose and not too clean but it works I guess, rep+ for the moderately hard work, although it would be nicer with dialogs and 3D text labes over the players heads if the speedboost is enabled, make it a filterscript, job well done.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)