OnPlayerKeyStateChange Problem
#1

Hello,

Well i've got a little problem when i try to add a script when you press on a KeyBoard key it does the action. Sorry for bad english ^^


Here's my compile

Код:
I:\Users\Misume\Documents\samp03dsvr_R2_win32\filterscripts\clig.pwn(103) : error 029: invalid expression, assumed zero
I:\Users\Misume\Documents\samp03dsvr_R2_win32\filterscripts\clig.pwn(103) : error 004: function "OnPlayerKeyStateChange" is not implemented
I:\Users\Misume\Documents\samp03dsvr_R2_win32\filterscripts\clig.pwn(105) : error 029: invalid expression, assumed zero
I:\Users\Misume\Documents\samp03dsvr_R2_win32\filterscripts\clig.pwn(115) : error 029: invalid expression, assumed zero
I:\Users\Misume\Documents\samp03dsvr_R2_win32\filterscripts\clig.pwn(130) : error 030: compound statement not closed at the end of file (started at line 93)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Errors.
Here's my script.
The top :

PHP код:
 #define FILTERSCRIPT
    #include <a_samp>
    #include <a_players>
    
    #define PRESSED(%0)
    #define newkeys(%0)
    #define oldkeys(%0)
    
    #define COLOR_YELLOW 0xFFFF00AA
    #define COLOR_WHITE 0xFFFFFFAA
    #define COLOR_GREEN 0x33AA33AA
    #define COLOR_PURPLE 0xB462F6F6
    #define MAX_STRING 255
    
    
new sendername;
    new 
Text3D:gauche[MAX_PLAYERS];
    new 
Text3D:droite[MAX_PLAYERS];
    new 
BigEar[MAX_PLAYERS];
    
    
#if defined FILTERSCRIPT
    #pragma tabsize 0 
And the script :

PHP код:
stock ProxDetector(Float:radiplayeridlen[],col1,col2,col3,col4,col5)
{
    if(
IsPlayerConnected(playerid)) {
        new 
Float:posxFloat:posyFloat:posz;
        new 
Float:oldposxFloat:oldposyFloat:oldposz;
        new 
Float:tempposxFloat:tempposyFloat:tempposz;
        
GetPlayerPos(playeridoldposxoldposyoldposz);
        for(new 
0MAX_PLAYERSi++) {
            if(
IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))) {
                if(!
BigEar[i]) {
                    
GetPlayerPos(iposxposyposz);
                    
tempposx = (oldposx -posx);
                    
tempposy = (oldposy -posy);
                    
tempposz = (oldposz -posz);
                    if (((
tempposx radi/16) && (tempposx > -radi/16)) && ((tempposy radi/16) && (tempposy > -radi/16)) && ((tempposz radi/16) && (tempposz > -radi/16))) SendClientMessage(icol1len);
                    else if (((
tempposx radi/8) && (tempposx > -radi/8)) && ((tempposy radi/8) && (tempposy > -radi/8)) && ((tempposz radi/8) && (tempposz > -radi/8))) SendClientMessage(icol2len);
                    else if (((
tempposx radi/4) && (tempposx > -radi/4)) && ((tempposy radi/4) && (tempposy > -radi/4)) && ((tempposz radi/4) && (tempposz > -radi/4))) SendClientMessage(icol3len);
                    else if (((
tempposx radi/2) && (tempposx > -radi/2)) && ((tempposy radi/2) && (tempposy > -radi/2)) && ((tempposz radi/2) && (tempposz > -radi/2))) SendClientMessage(icol4len);
                    else if (((
tempposx radi) && (tempposx > -radi)) && ((tempposy radi) && (tempposy > -radi)) && ((tempposz radi) && (tempposz > -radi))) SendClientMessage(icol5len);
                } else {
                    
SendClientMessage(icol1len);
                }
            }
        }
    }
    return 
1;
}
 new 
string[256];
 public 
OnPlayerCommandText(playeridcmdtext[])
{
        if (
strcmp("/cligon"cmdtexttrue10) == 0)
        {
                    
format(stringsizeof(string), "%s viens d'activer/dйsactiver ses clignotants"sendername);
                    
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    
SendClientMessage(playeridCOLOR_GREEN"Clignotant dйsactivй/activй");
                            
Delete3DTextLabel(gauche[playerid]);
                            
Delete3DTextLabel(droite[playerid]);
                            return 
1;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if (
PRESSED(KEY_LEFT))
    {
                            
SendClientMessage(playeridCOLOR_YELLOW"Vous mettez les clignotants gauche");
                            
format(stringsizeof(string), "** %s met son clignotant gauche.."sendername);
                            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                            
gauche[playerid] = Create3DTextLabel("<<== Clignotant gauche <<==",0x008B00FF,0,0,0,50,-1,1);
                            
Attach3DTextLabelToPlayer(gauche[playerid], playerid0,0,0);
                            return 
1;
                            }
    if (
PRESSED(KEY_RIGHT))
    {
                             
SendClientMessage(playeridCOLOR_YELLOW"Vous mettez les clignotants droite");
                            
format(stringsizeof(string), "** %s met son clignotant droite.."sendername);
                            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                            
droite[playerid] = Create3DTextLabel("==>> Clignotant droite ==>>",0x008B00FF,0,0,0,50,-1,1);
                            
Attach3DTextLabelToPlayer(gauche[playerid], playerid0,0,0);
                            return 
1;
                    }
            return 
0;
        } 

Thanks for helping.
Reply
#2

When I indent your code propertly see what I have:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/cligon", cmdtext, true, 10) == 0)
    {
        format(string, sizeof(string), "%s viens d'activer/dйsactiver ses clignotants", sendername);
        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        SendClientMessage(playerid, COLOR_GREEN, "Clignotant dйsactivй/activй");
        Delete3DTextLabel(gauche[playerid]);
        Delete3DTextLabel(droite[playerid]);
        return 1;
}
See?

Replace that with this:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/cligon", cmdtext, true, 10) == 0)
    {
        format(string, sizeof(string), "%s viens d'activer/dйsactiver ses clignotants", sendername);
        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        SendClientMessage(playerid, COLOR_GREEN, "Clignotant dйsactivй/activй");
        Delete3DTextLabel(gauche[playerid]);
        Delete3DTextLabel(droite[playerid]);
        return 1;
    }
    return 0;
}
Reply
#3

Oh lol i didn't see that thank you ! Now i got this error

Код:
I:\Users\Misume\Documents\samp03dsvr_R2_win32\filterscripts\clig.pwn(107) : error 029: invalid expression, assumed zero
I:\Users\Misume\Documents\samp03dsvr_R2_win32\filterscripts\clig.pwn(117) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
And the script :

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if (
PRESSED(KEY_LEFT)) // here is the error
    
{
                            
SendClientMessage(playeridCOLOR_YELLOW"Vous mettez les clignotants gauche");
                            
format(stringsizeof(string), "** %s met son clignotant gauche.."sendername);
                            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                            
gauche[playerid] = Create3DTextLabel("<<== Clignotant gauche <<==",0x008B00FF,0,0,0,50,-1,1);
                            
Attach3DTextLabelToPlayer(gauche[playerid], playerid0,0,0);
                            return 
1;
                            }
    if (
PRESSED(KEY_RIGHT)) // here is the error
    
{
                             
SendClientMessage(playeridCOLOR_YELLOW"Vous mettez les clignotants droite");
                            
format(stringsizeof(string), "** %s met son clignotant droite.."sendername);
                            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                            
droite[playerid] = Create3DTextLabel("==>> Clignotant droite ==>>",0x008B00FF,0,0,0,50,-1,1);
                            
Attach3DTextLabelToPlayer(gauche[playerid], playerid0,0,0);
                            return 
1;
                    }
            return 
0;
        } 
Reply
#4

add this
pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Reply
#5

Thanks for help guys ^^

I have one last question, when i use the cmd's IG the name of the user who uses the cmd's doesn't show
this is the script

PHP код:
                            format(stringsizeof(string), "** %s met son clignotant gauche.."sendername);
                            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); 
Reply
#6

Quote:
Originally Posted by Mearu
Посмотреть сообщение
Thanks for help guys ^^

I have one last question, when i use the cmd's IG the name of the user who uses the cmd's doesn't show
this is the script

PHP код:
                            format(stringsizeof(string), "** %s met son clignotant gauche.."sendername);
                            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE); 
pawn Код:
new sendername[MAX_PLAYER_NAME];
GetPlayerName( playerid, sendername, sizeof( sendername ) );
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)