command that only works if you picked up something?
#1

say you picked up a object...

then typed a command

then it went

and you tried again, but you didnt pick up the object, so the command didnt work.

would it be something like

pawn Код:
pickedup =1;

maybe?
Reply
#2

You would need to create a PVar or an array/enum.

pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid) {
    if(pickupid == 204) { // Use a variable to hold the pickup ID. But for this example, I've set a random number.
        SetPVarInt(playerid, "pickedUpPickup", 1); // As a PVar.
        playerPickedUpPickup[playerid] = 1; // As an array, this is faster than using a PVar. To declare it, use 'new playerPickedUpPickup[MAX_PLAYERS];'
    }
   
    return 1;
}
And in your command code to check whether your pickup was picked up:

pawn Код:
if(GetPVarInt(playerid, "pickedUpPickup") == 1) { // As a PVar
print("Hello World");
SetPVarInt(playerid, "pickedUpPickup", 0); // They need to pickup the pickup... again!
}
if(playerPickedUpPickup[playerid] == 1) { // As an array
print("Hello World");
playerPickedUpPickup[playerid] = 0; // They need to pickup the pickup... again!
}
"Hello World" would print if the pickup had been picked up.
Reply
#3

and if you want it in a cmd, here is how it works:
Код:
	if (strcmp("/cmd", cmdtext, true, 10) == 0)
	{
	if(playerPickedUpPickup[playerid] == 0)
	{
	SendClientMessage(playerid, COLOR_BRIGHTRED, "You Didn't Pick up the Pick-Up! Take it to use this cmd");
	}
	else
	{
               // rest of ur command
	playerPickedUpPickup[playerid] = 0;
	}
Reply
#4

thanks guys :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)