[FilterScript] Simple Drug System
#1


Hello people! So I decided to post a filterscript.
It is a drug system, I've maded, it is free to use, just please do not remove the credits.
Check my signature, positive reputation would be appriciated, I honestly need to post an advertisement for a server.
If you find any errors, mistakes, bugs, feel free to tell me and I will fix it and upload again, or you can fix it yourself.
Pastebin: https://pastebin.com/Z8vvkkTT
Direct DL: https://download2267.mediafire.com/d...rug-System.inc
Mediafire: https://www.mediafire.com/file/608d2...ystem.inc/file
Reply
#2

looks good, i will test this!
Reply
#3

Why wouldn't you just put all data into the enum instead?
Code:
new DrugTimer[MAX_PLAYERS];
new StonedTimer[MAX_PLAYERS];
new UsedDrug[MAX_PLAYERS];

enum pInfo{
	pCannabis,
	pCocaine
}
You only need to do this once either in OnPlayerConnect() or OnPlayerDisconnect() choose one not both.
Code:
public OnPlayerConnect(playerid)
{
	DrugTimer[playerid] = 0;
	StonedTimer[playerid] = 0;
	UsedDrug[playerid] = 0;
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	DrugTimer[playerid] = 0;
	StonedTimer[playerid] = 0;
	UsedDrug[playerid] = 0;
	return 1;
}
You really need to work on your logic structures or you are going to run into trouble
Code:
	if(strcmp(option, "cannabis", true) == 0)
	{
		if(gettime() < (DrugTimer[playerid] + 5))
		{
			format(str, sizeof(str), "You have to wait %d seconds before you can use /usedrug cannabis again!", (DrugTimer[playerid] + 5) - gettime());
			SendClientMessage(playerid, COLOR_GREY, str);
			return 1;
		}
		if(gettime() < (StonedTimer[playerid] + 120))
		{
			format(str, sizeof(str), "You have to wait %d seconds before you can use /usedrug cannabis again!", (StonedTimer[playerid] + 120) - gettime());
			SendClientMessage(playerid, COLOR_GREY, str);
			return 1;
		}
		GetPlayerHealth(playerid, Float:HP);
		if(PlayerInfo[playerid][pCannabis] < 1) return SendClientMessage(playerid, COLOR_GREY, "You do not have that much of Cannabis.");
		if(HP >= 100) return SendClientMessage(playerid, COLOR_GREY, "Your HP is already full!");
		if(HP >= 90) 
		{
			SetPlayerHealth(playerid, 100);
		}
		else if(HP < 90) 
		{
			SetPlayerHealth(playerid, HP+15);
		}
		SendClientMessage(playerid, COLOR_GREY, "You've used 2 grams of cannabis and recived +15 health");
		SetPlayerWeather(playerid, 2009);
		SetPlayerDrunkLevel(playerid, 9000);
		PlayerInfo[playerid][pCannabis] -=1;
		DrugTimer[playerid] = gettime();
		UsedDrug[playerid] ++;
		if(UsedDrug[playerid] >= 3)
		{
			SetTimerEx("RemoveDrugEffect", 60000*2, false, "i", playerid);
			UsedDrug[playerid] = 0;
			StonedTimer[playerid] = gettime();
		}
		return 1;
	}
Becomes

Code:
if(strcmp(option, "cannabis", true) == 0)
{
	if(gettime() < (DrugTimer[playerid] + 5))
	{
		format(str, sizeof(str), "You have to wait %d seconds before you can use /usedrug cannabis again!", (DrugTimer[playerid] + 5) - gettime());
		SendClientMessage(playerid, COLOR_GREY, str);
	}
	else if(gettime() < (StonedTimer[playerid] + 120))
	{
		format(str, sizeof(str), "You have to wait %d seconds before you can use /usedrug cannabis again!", (StonedTimer[playerid] + 120) - gettime());
		SendClientMessage(playerid, COLOR_GREY, str);
	}
	else
	{
		if(PlayerInfo[playerid][pCannabis] < 1)
			SendClientMessage(playerid, COLOR_GREY, "You do not have that much of Cannabis.");
		else
		{
			GetPlayerHealth(playerid, Float:HP);
			if(HP >= 100)
				SendClientMessage(playerid, COLOR_GREY, "Your HP is already full!");
			else
			{
				if(HP >= 90)
					SetPlayerHealth(playerid, 100);
				else if(HP < 90)
					SetPlayerHealth(playerid, HP+15);

				SendClientMessage(playerid, COLOR_GREY, "You've used 2 grams of cannabis and recived +15 health");
				SetPlayerWeather(playerid, 2009);
				SetPlayerDrunkLevel(playerid, 9000);
				PlayerInfo[playerid][pCannabis] -=1;
				DrugTimer[playerid] = gettime();
				UsedDrug[playerid] ++;

				if(UsedDrug[playerid] >= 3)
				{
					SetTimerEx("RemoveDrugEffect", 60000*2, false, "i", playerid);
					UsedDrug[playerid] = 0;
					StonedTimer[playerid] = gettime();
				}
			}
		}
	}
}
You just need to expand your code a bit more and build logic structures that can be followed. Using shitloads of returns is a horrible practice.

What is this horseshit? Did you even test this script? How the hell do you expect that to do anything?
Code:
new option[200], id, amount, str[100], Float:x, Float:y, Float:z;
    GetPlayerPos(id, Float:x, Float:y, Float:z);
Just had to point out the end of this script.
Code:
		return 1;
	}
	return 1;
}
You used return 35 times in this script! 35 times! There should only be 9 definitely a problem with your "return happy" ways.

This would normally be a 2-3 star script but it is incomplete! 1-Star in it's current state this is not a release fix it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)