Command needed to do other command
#1

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
Reply
#2

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!
Reply
#3

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

The Answer is givin already on the second psot
Reply
#5

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

#include <cps> i donno wats wrong :X
Reply
#6

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?
Reply
#7

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

DOESNT WORK, i can always do /usedrugs
Reply
#9

show your whole script?
Reply
#10

Код:
	//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;
	}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)