SA-MP Forums Archive
Command needed to do other command - 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: Command needed to do other command (/showthread.php?tid=79950)



Command needed to do other command - TehNobody - 01.06.2009

I want to make something like a drugs market, where you can buy the drugs
then i want to make /usedrugs or something liek that, but now i need to know, how to make the /usedrugs not work when someone didnt /buydrugs and how to let them use the drugs when someone DID buy them


Re: Command needed to do other command - Ignas1337 - 01.06.2009

you hsould create a variable like..
pawn Код:
new holdingDrugs[MAX_PLAYERS];//on top of script under include a_samp
next you need to assign a value to that when a player buys drugs. Do
pawn Код:
holdingDrugs[playerid] += 1; // or any other vaue. you can use strtok to set it then it would be... holdingDrugs[playerid] += tmp; or something like it.
Now to use drugs you do
pawn Код:
if(holdingDrugs[playerid] > 0) { /* do what happens when he uses the drugs and dont forget to reduce the holdingDrugs */ holdingDrugs[playerid] --;}
else { /* do here what message he/she hsould get when he doesn't have drugs. */}
hope it helped!


Re: Command needed to do other command - TehNobody - 01.06.2009

but how will the script know when the player has the drugs, and when not?


Re: Command needed to do other command - Castle - 01.06.2009

The Answer is givin already on the second psot


Re: Command needed to do other command - TehNobody - 01.06.2009

i got an error from fatal error 100: cannot read from file: "cps"

#include <cps> i donno wats wrong :X


Re: Command needed to do other command - Castle - 01.06.2009

Quote:
Originally Posted by TehNobody
i got an error from fatal error 100: cannot read from file: "cps"

#include <cps> i donno wats wrong :X
Are you 100% sure you have that file in the includes folder?


Re: Command needed to do other command - TehNobody - 01.06.2009

ywa, i already downloaded teh include again and replaced, but still erorr


Re: Command needed to do other command - TehNobody - 01.06.2009

DOESNT WORK, i can always do /usedrugs


Re: Command needed to do other command - Think - 01.06.2009

show your whole script?


Re: Command needed to do other command - TehNobody - 01.06.2009

Код:
	//Drugs:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  if (strcmp("/buydrugs", cmdtext, true) == 0)
	{
	if(PlayerToPoint(2, playerid, 1253.7599,-1835.2896,13.3896))
	{
	SendClientMessage(playerid, 0xFFFF00A, "You have bought some drugs");
	}
	else
	{
	SendClientMessage(playerid, 0xFF000AA, "You are not at the drugs market"); }
	return 1;
	}
	
	//use drugs
  if (strcmp("/usedrugs", cmdtext, true) == 0)
	{
	holdingDrugs[playerid] += 1; // or any other vaue. you can use strtok to set it then it would be... holdingDrugs[playerid] += tmp; or something like it.
	if(holdingDrugs[playerid] > 0)
	{
	SendClientMessage(playerid, 0xFFFF00A, "You have Used 1 Gram of drugs");
	}
	else
	{
	SendClientMessage(playerid, 0xFF000AA, "You have no drugs to use"); }
	return 1;
	}