Creating drug script
#1

Hey, I must first say that my english understanding is not always good, especially when it comes to advanced english wich I found in the pawn.pdf so I have not continued to read it.

However, I was looking at some gamemode scripts earlier where they had drugs and drug smuggling in their gamemode and I am not here to ask how to make it, I will rather find out on my own. I am here to see if I could do it a better way then what I currently have done!

Here is my script, it compiles 100% and my two commands work ingame, I can get drugs and see the drugs.

Код:
new Drugs[MAX_PLAYERS];
First of, I used the same way I saw a guy use for wanted system (if you kill a person you gain +wanted stars each kill) and I thought, Maybe use the same for my drugs script!

Код:
	if (strcmp(cmdtext, "/getdrugs", true)==0)
	{
	  new oldlevel;
 	  new newlevel;
 	  oldlevel = Drugs[playerid];
  	  newlevel = oldlevel + 1;
      Drugs[playerid] = newlevel;
      SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have been given 1G drugs!");
	  return 1;
	}
But here is my concern, script below makes my script look so messy because I repeat same script piece over and over again just to get one result.

Can I make this easier instead of constantly adding if(drugs[playerid] == X) ? How can I make a line that just lookup what value i have instead of asking if I have 1,2,3,4 and so on?

Код:
 // ============================================= //
  if (strcmp(cmdtext, "/drugs", true)==0)
	{
    if(gJob[playerid] == JOB_CIVILIAN)
    {
      if(Drugs[playerid] == 0)
      {
    	SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have no drugs on you!");
			}
			else if(Drugs[playerid] == 1)
      {
    	SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have 1g drugs on you!");
			}
			else if(Drugs[playerid] == 2)
      {
    	SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have 2g drugs on you!");
			}
		}
		return 1;
	 }
  // ============================================= //

Also I would like to know if it is stupid to use the script I am using? Should I make it diffrent,easier to understand? Could it make my gamemode lag or get bugged because I use this or that code?

I hope you understand, this is not matter of searching on the forum for help, I ask for guidance so I do not make a very very long script that maybe end up very buggy or laggy for my gamemode. Or can I continue using the codes I have been using.
Reply


Messages In This Thread
Creating drug script - by frRic - 05.04.2008, 04:07
Re: Creating drug script - by Cueball - 05.04.2008, 05:03
Re: Creating drug script - by frRic - 05.04.2008, 05:29
Re: Creating drug script - by MKMS - 01.05.2008, 00:36
Re: Creating drug script - by Pghpunkid - 01.05.2008, 01:57
Re: Creating drug script - by klavins21 - 16.06.2008, 14:44
Re: Creating drug script - by Pghpunkid - 29.06.2008, 18:47
Re: Creating drug script - by mamorunl - 29.06.2008, 23:55
Re: Creating drug script - by Cueball - 30.06.2008, 06:56
Re: Creating drug script - by mamorunl - 30.06.2008, 09:47

Forum Jump:


Users browsing this thread: 1 Guest(s)