SA-MP Forums Archive
Drug system - 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: Drug system (/showthread.php?tid=361672)



Drug system - thefatshizms - 21.07.2012

Hello, i want to create a drug system

question is how would i do a cmd to sell the drugs that you have (with varibles i thnk) like sell 500 grams etc but you gotta have 500grams.

thanks soz for bad typos im in a rush (not good fast typer)


Re: Drug system - Youice - 21.07.2012

go here, ; )


Re: Drug system - thefatshizms - 21.07.2012

im not asking for someone to do it for me im asking for someone to tell me how i would do it -_-


Re: Drug system - Youice - 21.07.2012

(oka-ay), I will re-post an explain...


Re: Drug system - [KHK]Khalid - 21.07.2012

You know how to make commands already ha? If so then I can give you some hints:

pawn Код:
// This is a per-player global variable which will be used to store a player's drugs in
new Drugs[MAX_PLAYERS];

// Some useful stocks you might need
stock GivePlayerDrugs(playerid, amount)
{
    Drugs[playerid] += amount; // adds amount to the current player's drugs
    return 1;
}

stock GetPlayerDrugs(playerid)
{
    return Drugs[playerid]; // returns the amount of drugs that a player has
}

// In your command
if(GetPlayerDrugs(playerid) < 500) // Here comes the stock we made. If the player doesn't have (+)500 drugs
    return SendClientMessage(playerid, -1, "You must have 500 grams of drugs to use this command!"); // return error



Re: Drug system - thefatshizms - 21.07.2012

ahh thank you so much yes i can make that but not really done anything like this :/ but you opened my eyes thanks! +2 rep


Re: Drug system - Youice - 21.07.2012

Код:
new gPlayerDrugs[MAX_PLAYERS char];
new bool:InDrugDealOffer[MAX_PLAYERS];
new ValueOffered;

CMD:selldrugs(playerid, cmdtext[])
{
	new TargetID, value, str[185], pname[MAX_PLAYER_NAME];
	if(sscanf(cmdtext, "di", TargetID, value)) SendClientMessage(playerid, -1, "USAGE: /selldrugs [playerid] [ammount]"); //Im sure that you know, what sscanf is...
	if(TargetID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Invalid player ID");//if Target id is invalid
	if(gPlayerDrugs{playerid} >= 1) //if the player have drugs
	{
	    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
		format(str, sizeof(str), "%s is offering you (%d) drugs, (/accept drugs)", pname, value);
		SendClientMessage(TargetID, -1, str);
		InDrugDealOffer[TargetID] = true;
		ValueOffered = value;//storing the value he is offering
	}
	else SendClientMessage(playerid, -1, "you don't have any drugs to sell"); //it appears when the playerid doesn't have any drugs, like 0 drugs
	return 1;
}

CMD:accept(playerid, params[])
{
    if(sscanf(params, "s", params))
	{
	 	SendClientMessage(playerid, -1, "USAGE: /accept [name]");
	 	SendClientMessage(playerid, -1, "Available Names: drugs");
	}
	if (strcmp("drugs", params, true) == 0)
	{
		if(InDrugDealOffer[playerid] == true)//if some one is offering him drugs
		{
		    SendClientMessage(playerid, -1, "You have accepted the offer"); //a client message for sure and 1/2 the succeed of the cmd
			gPlayerDrugs{playerid} = ValueOffered;//the value he offered
		}
		return 1;
	}
	return 1;
}
it's like hints... (not the code of using) not even tested