Anti-DB script help
#1

hi, i try do a anti-db (drive by) script but for some reason when i compile show me a erro =S here my script
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	new estado = GetPlayerState(playerid);
	if (IsPlayerInAnyVehicle(playerid) && estado == PLAYER_STATE_DRIVER)
	{
		if (newkeys == ((KEY_FIRE || KEY_ACTION) && (KEY_LOOK_RIGHT || KEY_LOOK_LEFT)))
		{
			new Float:x,Float:y, Float:z;
			GetPlayerPos(playerid,Float:x,Float:y, Float:z);
			SetPlayerPos(playerid,Float:x+10,Float:y+1, Float:z);
			SendClientMessage(playerid,0xcc3300ff,"DANGER: Remove From vehicule for Drive-By");
		}
	}
}
when i compile show this error
ChrisDM.pwn(397) : warning 213: tag mismatch
Reply
#2

I realized that detects when OnPlayerKeyStateChange only 1 key press, how can I do to detect when 2 or more keys pressed simultaneously?.
Reply
#3

....
Reply
#4

Quote:
Originally Posted by [TPG
Coole210 ]
Make the same script twice?
mmmmm read the first key presed but not 2 simultaneously. this can do with GetPlayerKey?
Reply
#5

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new estado = GetPlayerState(playerid);
    if (IsPlayerInAnyVehicle(playerid) && estado == PLAYER_STATE_DRIVER)
    {
        if (newkeys == KEY_FIRE && KEY_LOOK_RIGHT || newkeys == KEY_FIRE && KEY_LOOK_LEFT || newkeys == KEY_ACTION && KEY_LOOK_LEFT || newkeys == KEY_ACTION && KEY_LOOK_RIGHT)
        {
            new Float:x,Float:y, Float:z;
            GetPlayerPos(playerid,Float:x,Float:y, Float:z);
            SetPlayerPos(playerid,Float:x+10,Float:y+1, Float:z);
            SendClientMessage(playerid,0xcc3300ff,"DANGER: Remove From vehicule for Drive-By");
        }
    }
}
Try this code, should work.
Reply
#6

GetPlayerPos(playerid, Float:x, Float:y, Float:z);
SetPlayerPos(playerid, Float:x+10, Float:y+1, Float:z);

Remove the red parts (see above) from your code and it'll go fine.
Reply
#7

For the key detection use "&" (bit AND) and "|" (bit OR) operators, like this:
pawn Код:
if (newkeys & ((KEY_FIRE | KEY_ACTION) & (KEY_LOOK_RIGHT | KEY_LOOK_LEFT)))
See pawn-lang.pdf and wiki for more information.

Quote:
Originally Posted by Finn
GetPlayerPos(playerid, Float:x, Float:y, Float:z);
SetPlayerPos(playerid, Float:x+10, Float:y+1, Float:z);
Remove the red parts (see above) from your code and it'll go fine.
No, this code is ok and should not cause any compiler warnings.

EDIT: https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Reply
#8

Quote:
Originally Posted by ZeeX
Quote:
Originally Posted by Finn
GetPlayerPos(playerid, Float:x, Float:y, Float:z);
SetPlayerPos(playerid, Float:x+10, Float:y+1, Float:z);
Remove the red parts (see above) from your code and it'll go fine.
No, this code is ok and should not cause any compiler warnings.
Haven't really paid attention if that makes warnings or not and couldn't be arsed to check it out in the compiler, but it's cool you checked it out and corrected my mistake.

In my opinion keeping 'Float:' in the function makes it look ugly, which is the reason I don't keep them in my code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)