Syringe script
#1

Hey, I am trying to create a command which sets the target player frozen and their drunk level, but I can not make this command work. What am I doing wrong?

Код:
CMD:syringe(playerid, params[])
{
	new id;
	if(sscanf(params, "ud", id)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /syringe [ID]");
	
		if(!IsPlayerInAnyVehicle(playerid));
		{
		    TogglePlayerControllable(id, 0);
		    SetPlayerDrunkLevel(id, 10000);
		}
		else
		{
	    	SendClientMessage(playerid, COLOR_ORANGE, "You have to be on foot to use the syringe!");
		}
		return 1;
}
Reply
#2

Код:
CMD:syringe(playerid, params[])
{
	if(sscanf(params, "d", params[0])) return SendClientMessage(playerid, COLOR_GREY, "Usage: /syringe [ID]");
	if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "You have to be on foot to use the syringe!");
        TogglePlayerControllable(params[0], 0);
	SetPlayerDrunkLevel(params[0], 10000);
	return 1;
}
Reply
#3

Quote:
Originally Posted by Stuntff
Посмотреть сообщение
Код:
CMD:syringe(playerid, params[])
{
	if(sscanf(params, "d", params[0])) return SendClientMessage(playerid, COLOR_GREY, "Usage: /syringe [ID]");
	if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "You have to be on foot to use the syringe!");
        TogglePlayerControllable(params[0], 0);
	SetPlayerDrunkLevel(params[0], 10000);
	return 1;
}
Works great! How could I make it so that the TogglePlayerControllable and SetPlayerDrunkLevel are set to false after 10 seconds have passed?
Reply
#4

Код:
CMD:syringe(playerid, params[])
{
	if(sscanf(params, "d", params[0])) return SendClientMessage(playerid, COLOR_GREY, "Usage: /syringe [ID]");
	if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "You have to be on foot to use the syringe!");
        TogglePlayerControllable(params[0], 0);
	SetPlayerDrunkLevel(params[0], 10000);
        SetTimerEx("SyringeSec", 10000, true, "d", playerid);
	return 1;
}
forward SyringeSec(playerid);
public SyringeSec(playerid
{
        TogglePlayerControllable(params[0], 1);
	SetPlayerDrunkLevel(params[0], 0);
        return 1;
}
Reply
#5

Quote:
Originally Posted by FuNkYTheGreat
Посмотреть сообщение
Код:
CMD:syringe(playerid, params[])
{
	if(sscanf(params, "d", params[0])) return SendClientMessage(playerid, COLOR_GREY, "Usage: /syringe [ID]");
	if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "You have to be on foot to use the syringe!");
        TogglePlayerControllable(params[0], 0);
	SetPlayerDrunkLevel(params[0], 10000);
        SetTimerEx("SyringeSec", 10000, true, "d", playerid);
	return 1;
}
forward SyringeSec(playerid);
public SyringeSec(playerid
{
        TogglePlayerControllable(params[0], 1);
	SetPlayerDrunkLevel(params[0], 0);
        return 1;
}
Returns with many errors.
Reply
#6

Код:
CMD:syringe(playerid, params[])
{
	if(sscanf(params, "d", params[0])) return SendClientMessage(playerid, COLOR_GREY, "Usage: /syringe [ID]");
	if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "You have to be on foot to use the syringe!");
        TogglePlayerControllable(params[0], 0);
	SetPlayerDrunkLevel(params[0], 10000);
        SetTimerEx("SyringeSec", 10000, true, "d", playerid);
	return 1;
}
forward SyringeSec(playerid);
public SyringeSec(playerid)
{
        TogglePlayerControllable(playerid, 1);
	SetPlayerDrunkLevel(playerid, 0);
        return 1;
}
Try it.
Reply
#7

Quote:
Originally Posted by FuNkYTheGreat
Посмотреть сообщение
Код:
CMD:syringe(playerid, params[])
{
	if(sscanf(params, "d", params[0])) return SendClientMessage(playerid, COLOR_GREY, "Usage: /syringe [ID]");
	if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "You have to be on foot to use the syringe!");
        TogglePlayerControllable(params[0], 0);
	SetPlayerDrunkLevel(params[0], 10000);
        SetTimerEx("SyringeSec", 10000, true, "d", playerid);
	return 1;
}
forward SyringeSec(playerid);
public SyringeSec(playerid)
{
        TogglePlayerControllable(playerid, 1);
	SetPlayerDrunkLevel(playerid, 0);
        return 1;
}
Try it.
Код:
SetTimerEx("SyringeSec", 10000, false, "d", params[0]);
Not repeating timer for the player specified not the player who executed the command.
Reply
#8

Quote:
Originally Posted by FuNkYTheGreat
Посмотреть сообщение
Код:
CMD:syringe(playerid, params[])
{
	if(sscanf(params, "d", params[0])) return SendClientMessage(playerid, COLOR_GREY, "Usage: /syringe [ID]");
	if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "You have to be on foot to use the syringe!");
        TogglePlayerControllable(params[0], 0);
	SetPlayerDrunkLevel(params[0], 10000);
        SetTimerEx("SyringeSec", 10000, true, "d", playerid);
	return 1;
}
forward SyringeSec(playerid);
public SyringeSec(playerid)
{
        TogglePlayerControllable(playerid, 1);
	SetPlayerDrunkLevel(playerid, 0);
        return 1;
}
Try it.
Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Код:
SetTimerEx("SyringeSec", 10000, false, "d", params[0]);
Not repeating timer for the player specified not the player who executed the command.
Works well, but one more thing: I tried to make it so you can not perform the command on yourself, but the compiler is giving me the following error.

Код:
error 017: undefined symbol "giveplayerid"
The code itself:


Код:
CMD:syringe(playerid, params[])
{
	if(sscanf(params, "d", params[0])) return SendClientMessage(playerid, COLOR_GREY, "Usage: /syringe [ID]");
	if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "You have to be on foot to use the syringe!");
	if(giveplayerid == playerid) return SendClientMessage(playerid, COLOR_GREY, "You can not use this command on yourself!");
	TogglePlayerControllable(params[0], 0);
	SetPlayerDrunkLevel(params[0], 10000);
	SetTimerEx("SyringeSec", 10000, false, "d", params[0]);
	return 1;
	
 	}
	forward SyringeSec(playerid);
	public SyringeSec(playerid)
	{
	TogglePlayerControllable(playerid, 1);
	SetPlayerDrunkLevel(playerid, 0);
 	return 1;
}
Reply
#9

You have never made a new variable called 'giveplayerid' but you are using 'params[0]'.

From
PHP код:
if(giveplayerid == playerid) return SendClientMessage(playeridCOLOR_GREY"You can not use this command on yourself!"); 
To
PHP код:
if(params[0] == playerid) return SendClientMessage(playeridCOLOR_GREY"You can not use this command on yourself!"); 
Reply
#10

I tried to restrict the script to hitmen only, but I have faced new problems.

Код:
./includes/commands.pwn(55781) : error 029: invalid expression, assumed zero
./includes/commands.pwn(55781) : error 017: undefined symbol "SyringeSec"
./includes/commands.pwn(55782) : error 029: invalid expression, assumed zero
./includes/commands.pwn(55782) : error 017: undefined symbol "SyringeSec"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
The code itself:

Код:
CMD:syringe(playerid, params[])
{
	if(IsAHitman(playerid))
	{	
		new id;
		if(sscanf(params, "d", id)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /syringe [ID]");
		if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "You have to be on foot to use the syringe!");
		if(id == playerid) return SendClientMessage(playerid, COLOR_GREY, "You can not use this command on yourself!");
		TogglePlayerControllable(id, 0);
		SetPlayerDrunkLevel(id, 10000);
		SetTimerEx("SyringeSec", 10000, false, "d", id);
		return 1;
	}
	else 
	{
		SendClientMessageEx(playerid, COLOR_GREY, "You are not a member of the hitman agency!");
	}
		forward SyringeSec(playerid);
		public SyringeSec(playerid)
	{
		TogglePlayerControllable(playerid, 1);
		SetPlayerDrunkLevel(playerid, 0);
		return 1;
	}
}
Line 55781 is forward SyringeSec(playerid);
Line 55782 is public SyringeSec(playerid)
Reply


Forum Jump:


Users browsing this thread: