SA-MP Forums Archive
Disabling Functions in Zcmd if a pickupid is active - 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: Disabling Functions in Zcmd if a pickupid is active (/showthread.php?tid=464785)



Disabling Functions in Zcmd if a pickupid is active - Snakekeeper - 19.09.2013

Hello there

I would like to make it to where if the pickup "rdcenter" is active and created, to Display the Clientmsg

And if the pickup is destroyed I want it to Do the functions As followed.

Here is the sample from the Cmd im having problems with

Код:
CMD:resetm(playerid, params[])
	{
	if(RCON || RDMEMBER)
    {
    if//(the pickup is created)
	{
 	SendClientMessage(playerid, green, "[RD-INFO]: Missle Control System Dosent Need to be Reset");
 	}
	if//(the pickup is destroyed)
    {
 	SendClientMessage(playerid, green, "[RD-INFO]: Missle Control System Has Been Reset");
  	MoveDynamicObject(rocket1, -858.47668, -1956.97327, 14.92840, 45.0, 3296329728, 3296329728, 3296329728);
  	MoveDynamicObject(rocket2, -859.48608, -1956.94385, 14.92840, 45.0, 3296329728, 3296329728, 3296329728);
  	MoveDynamicObject(rocket3, -860.43353, -1956.92773, 14.92840, 45.0, 3296329728, 3296329728, 3296329728);
  	MoveDynamicObject(rocketdoor, -859.36591, -1956.96252, 17.88272, 25.0, 3296329728, 3296329728, 3296329728);
  	DestroyObject(sf);
  	DestroyObject(lv);
  	DestroyObject(mntc);
  	DestroyObject(ls);
  	DestroyObject(area69);
  	DestroyObject(rdb);
  	DestroyObject(nuke);
  	DestroyObject(rdlight1);
  	DestroyObject(rdlight2);
  	DestroyObject(rdlight3);
  	DestroyObject(rdlight4);
  	GangZoneStopFlashForAll(lvzone);
  	GangZoneStopFlashForAll(mtnzone);
  	GangZoneStopFlashForAll(sfzone);
  	GangZoneStopFlashForAll(zone69);
  	GangZoneStopFlashForAll(rdzone);
  	GangZoneStopFlashForAll(lszone);
  	GangZoneStopFlashForAll(nukezone);
  	GangZoneHideForAll(lvzone);
  	GangZoneHideForAll(mtnzone);
  	GangZoneHideForAll(sfzone);
  	GangZoneHideForAll(zone69);
  	GangZoneHideForAll(lszone);
  	GangZoneHideForAll(rdzone);
  	GangZoneHideForAll(nukezone);
  	light1 = CreateObject(18652, -807.51630, -1941.34705, 27.33774,   0.00000, 0.00000, -63.36000);
  	light2 = CreateObject(18652, -806.53241, -1938.60205, 27.33420,   0.00000, 0.00000, 26.46000);
  	light3 = CreateObject(18652, -809.39362, -1937.83618, 27.33596,   0.00000, 0.00000, -63.36000);
  	light4 = CreateObject(18652, -810.34229, -1940.59924, 27.32861,   0.00000, 0.00000, 26.88000);
  	rdcenter = CreatePickup(2976, 1, -811.1993, -1934.3029, 25.3736, -1);
  	}
 	}
    else
    {
	SendClientMessage(playerid, 0xFF0000FF, "[RD-INFO]: You need to be an RD member to use this cmd");
	}
	return 1;
	}
Kinda In a hurry, any help is appreciated.


Re: Disabling Functions in Zcmd if a pickupid is active - Lordzy - 19.09.2013

You can set variables in the cases where the pickup gets destroyed. And so, detect if it matches with what you want.
pawn Код:
//Example:
new Picked[MAX_PLAYERS]; //An variable which is used to detect if player has picked.
new pickDestroyed = 0; //Whether the pickup is destroyed or not.
public OnPlayerPickupPickup(playerid, pickupid)
{
 if(pickupid == Examplestuff)
 {
  pickDestroyed = 1; //Pickup has been destroyed.
  Picked[playerid] = 1; //The player has picked.
 //Rest codes...
 }
 return 1;
}

CMD:test(playerid, params[])
{
 if(pickDestroyed == 1 && Picked[playerid] == 1) SendClientMessage(playerid, -1, "You're the one who picked up and destroyed it!");
 else if(pickDestroyed == 1 && Picked[playerid] != 1) SendClientMessage(playerid, -1, "Someone has destroyed the pickup!");
 else if(pickDestroyed != 1) SendClientMessage(playerid, -1, "Pickup is still there!");
 return 1;
}



Re: Disabling Functions in Zcmd if a pickupid is active - Snakekeeper - 19.09.2013

Is there anyway i can just confine it to the "resetm" cmd, OnPlayerPickupPickup() for rdcenter just displays a Dialog. And a selected option destroys the pick up aka "rdcenter" to prevent bugs and abuse.


Re: Disabling Functions in Zcmd if a pickupid is active - Lordzy - 19.09.2013

You can use those variable setting under the command or at the response of the dialog. In case if you want to execute the command "resetm", under the pickup, you could do something like this:
pawn Код:
CMD:test1(playerid, params[])
{
 print("Hi");
 return 1;
}

CMD:test2(playerid, params[])
{
 return cmd_test1(playerid, params); //Executes "CMD:test1" here.
}

//The same can be used in callbacks too.



Re: Disabling Functions in Zcmd if a pickupid is active - Snakekeeper - 19.09.2013

Let me reprase, If the pickup is live i want it to return "cant reset the sys"
and if the pickup is Destroyed. i want it it to reset the sys.

The info you gave only returns "Cant be reset"

Heres the code

FYI, i dont want this just for singles players, the pickup and resetm is for all, not just on one player using the cmd

Код:
CMD:resetm(playerid, params[])
	{
	if(RCON || RDMEMBER || Snake || Cobra || Jenna || took)
    {
    if(pickDestroyed != 1)
    {
 	SendClientMessage(playerid, green, "[RD-INFO]: Missle Control System Dosent Need to be Reset");
	}
	else if(pickDestroyed == 1 && Picked[playerid] != 1)
	{
 	SendClientMessage(playerid, green, "[RD-INFO]: Missle Control System Has Been Reset");
  	MoveDynamicObject(rocket1, -858.47668, -1956.97327, 14.92840, 45.0, 3296329728, 3296329728, 3296329728);
  	MoveDynamicObject(rocket2, -859.48608, -1956.94385, 14.92840, 45.0, 3296329728, 3296329728, 3296329728);
  	MoveDynamicObject(rocket3, -860.43353, -1956.92773, 14.92840, 45.0, 3296329728, 3296329728, 3296329728);
  	MoveDynamicObject(rocketdoor, -859.36591, -1956.96252, 17.88272, 25.0, 3296329728, 3296329728, 3296329728);
  	DestroyObject(sf);
  	DestroyObject(lv);
  	DestroyObject(mntc);
  	DestroyObject(ls);
  	DestroyObject(area69);
  	DestroyObject(rdb);
  	DestroyObject(nuke);
  	DestroyObject(rdlight1);
  	DestroyObject(rdlight2);
  	DestroyObject(rdlight3);
  	DestroyObject(rdlight4);
  	GangZoneStopFlashForAll(lvzone);
  	GangZoneStopFlashForAll(mtnzone);
  	GangZoneStopFlashForAll(sfzone);
  	GangZoneStopFlashForAll(zone69);
  	GangZoneStopFlashForAll(rdzone);
  	GangZoneStopFlashForAll(lszone);
  	GangZoneStopFlashForAll(nukezone);
  	GangZoneHideForAll(lvzone);
  	GangZoneHideForAll(mtnzone);
  	GangZoneHideForAll(sfzone);
  	GangZoneHideForAll(zone69);
  	GangZoneHideForAll(lszone);
  	GangZoneHideForAll(rdzone);
  	GangZoneHideForAll(nukezone);
  	light1 = CreateObject(18652, -807.51630, -1941.34705, 27.33774,   0.00000, 0.00000, -63.36000);
  	light2 = CreateObject(18652, -806.53241, -1938.60205, 27.33420,   0.00000, 0.00000, 26.46000);
  	light3 = CreateObject(18652, -809.39362, -1937.83618, 27.33596,   0.00000, 0.00000, -63.36000);
  	light4 = CreateObject(18652, -810.34229, -1940.59924, 27.32861,   0.00000, 0.00000, 26.88000);
  	rdcenter = CreatePickup(2976, 1, -811.1993, -1934.3029, 25.3736, -1);
  	}
 	}
    else
    {
	SendClientMessage(playerid, 0xFF0000FF, "[RD-INFO]: You need to be an RD member to use this cmd");
	}
	return 1;
	}
Compiles great, just returns cant reset, even when the pickup is destroyed