SA-MP Forums Archive
Do this work ? - 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: Do this work ? (/showthread.php?tid=75218)



Do this work ? - Bearfist - 29.04.2009

Could this work...@ home everybody sleeps
so can't testing >D....

I want to script that only One DrugDealer Is Allowed In my GunGame
and if another player wants to be a dealer he gets the message

We Already Have A DrugDealer...We don't need another more!

To that work ?

Код:
  if(strcmp("/ddealer",cmdtext,true) == 0)
  {
	GetPlayerName(playerid,name,sizeof(name));
	
	if(drugdealer[playerid] == 0)
  {
  drugdealer[playerid] = 1;
  SendClientMessage(playerid,COLOR_YELLOW,"What Up Thug...Get Some Drugs by Press /drughelp");
  }
  else if(drugdealer[playerid] >= 1)
  {
  drugdealer[playerid] = 0;
  SendClientMessage(playerid,COLOR_RED,"We Already Have A DrugDealer...We don't need another more!");
  }
  else
  {
  drugdealer[playerid] = 0;
  }
  return 1;
  }
Bearfist


Re: Do this work ? - pen_theGun - 29.04.2009

I think.. NO


Re: Do this work ? - Bearfist - 29.04.2009

Very Helpful man!
...
could you say how I have to do it ?

Bearfist


Re: Do this work ? - pen_theGun - 29.04.2009

Quote:
Originally Posted by Bearfist
Very Helpful man!
tstststs
Quote:
Originally Posted by Bearfist
Could this work...@ home everybody sleeps
....
To that work ?
Short question = short answer!

Quote:
Originally Posted by Bearfist
could you say how I have to do it ?
now here you go \/ \/

pawn Код:
Top,
new drugdealer;

public OnGameModeInit()
{
    drugdealer=INVALID_PLAYER_ID;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp("/ddealer",cmdtext,true) == 0)
  {
    if(drugdealer[playerid] == INVALID_PLAYER_ID)
        drugdealer=playerid,
        SendClientMessage(playerid,COLOR_YELLOW,"What Up Thug...Get Some Drugs by Press /drughelp");
    else
        SendClientMessage(playerid,COLOR_RED,"We Already Have A DrugDealer...We don't need another more!");
    return 1;
  }
}

Also,
public OnPlayerDisconnect(playerid, reason)
{
    if(playerid==drugdealer)
        drugdealer=INVALID_PLAYER_ID;
}



Re: Do this work ? - Bearfist - 30.04.2009

Don't work =(

I got this errors:

(2410) : error 028: invalid subscript (not an array or too many subscripts): "drugdealer"
(2410) : warning 215: expression has no effect
(2410) : error 001: expected token: ";", but found "]"
(2410) : error 029: invalid expression, assumed zero

in these line:
Код:
 if(drugdealer[playerid] == INVALID_PLAYER_ID)
In this function:
Код:
if(strcmp("/dd",cmdtext,true) == 0)
  {
  if(drugdealer[playerid] == INVALID_PLAYER_ID)
  drugdealer=playerid;
  SendClientMessage(playerid,COLOR_YELLOW,"What Up Thug...Get Some Drugs by Press /drughelp");
  else
  SendClientMessage(playerid,COLOR_RED,"We Already Have A DrugDealer...We don't need Another One!");
	return 1;
  }
Why doesn't it want to work ? ...

Bearfist


Re: Do this work ? - pen_theGun - 30.04.2009

Quote:
Originally Posted by Bearfist
I got this errors:
in these line:
Код:
 if(drugdealer[playerid] == INVALID_PLAYER_ID)
yup, my bad

change it to :
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp("/ddealer",cmdtext,true) == 0)
  {
    if(drugdealer == INVALID_PLAYER_ID)
        drugdealer=playerid,
        SendClientMessage(playerid,COLOR_YELLOW,"What Up Thug...Get Some Drugs by Press /drughelp");
    else
        SendClientMessage(playerid,COLOR_RED,"We Already Have A DrugDealer...We don't need another more!");
    return 1;
  }
}



Re: Do this work ? - D101h - 30.04.2009

That solution will make playerid 0 as default drugdealer, it would be better to set the variable -1 as default.


Re: Do this work ? - Bearfist - 30.04.2009

That Worked ...
But when I set drugdealer to 0 I can't make me to drugdealer more o.O

...whatever
it don't matter ..isn't sooo important ! xD

But Thanks All =)

Bearfist