SA-MP Forums Archive
Can you tell me what's the problem? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Can you tell me what's the problem? (/showthread.php?tid=249774)



Can you tell me what's the problem? - Cjgogo - 20.04.2011

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
    new vehicleid=GetPlayerVehicleID(playerid);
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
       GetVehicleModel(vehicleid);
       if(vehicleid == 431)
       {
          GetPlayerSpeed(playerid,true);
          if(GetPlayerSpeed(playerid,true) > 60)
          {
             GameTextForPlayer(playerid,"A bomb has been planted on your bus,don't slow down below 50mph or you'll be blowed up",7500,4);
             if(PRESSED(KEY_BRAKE/REVERSE))
             {
                GetPlayerSpeed(playerid,true);
                if(GetPlayerSpeed(playerid,true) < 50)
                {
                   SetVehicleHealth(vehicleid,0);
                   SendClientMessage(playerid,RED,"BYE BYE!!!");
                }
             }
          }
       }
     }
    return 1;
}
Compiling errors:

D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_win32\gamemodes\lsdm.pwn(3 72) : error 017: undefined symbol "newkeys"


Re: Can you tell me what's the problem? - Mean - 20.04.2011

You put that in OnPlayerKeyStateChange not OnPlayerStateChange!


Re: Can you tell me what's the problem? - Cjgogo - 20.04.2011

lolz I did this

public OnPlayerKeyStateChange
{
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
return 1;
}

Compiling errors : undefined PRESSED


Re: Can you tell me what's the problem? - Mean - 20.04.2011

Hey WHY the hell are you adding a PRESSED define into OnPlayerStateChange( I just noticed ).


Re: Can you tell me what's the problem? - Cjgogo - 20.04.2011

I deleted it from there and added it to OnPlayerKeyStateChange as you told me but still thaat error.DO YOU KNOW HOW MUCH TOOK me to do that script,first i tried with dialogs(spammed all froum with my topics :P),and now I gave up the dialog idea and tried this,and this seem to be working only 1 ewrror udnefined PRESS


Re: Can you tell me what's the problem? - Cjgogo - 20.04.2011

more exaxtly I did this:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{

    new vehicleid=GetPlayerVehicleID(playerid);
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
       GetVehicleModel(vehicleid);
       if(vehicleid == 431)
       {
          GetPlayerSpeed(playerid,true);
          if(GetPlayerSpeed(playerid,true) > 60)
          {
             GameTextForPlayer(playerid,"A bomb has been planted on your bus,don't slow down below 50mph or you'll be blowed up",7500,4);
             if(PRESSED(KEY_BRAKE/REVERSE))
             {
                GetPlayerSpeed(playerid,true);
                if(GetPlayerSpeed(playerid,true) < 50)
                {
                   SetVehicleHealth(vehicleid,0);
                   SendClientMessage(playerid,RED,"BYE BYE!!!");
                }
             }
          }
       }
     }
    return 1;
}

public OnPlayerKeyStateChange
{
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
    return 1;
}



Re: Can you tell me what's the problem? - Stigg - 20.04.2011

Put it at the top of your gm with your other defines. Not in a callback.

pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
Simple.


Re: Can you tell me what's the problem? - Cjgogo - 20.04.2011

OK,I did that now the script looks like this:

pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnPlayerStateChange(playerid, newstate, oldstate)
{

    new vehicleid=GetPlayerVehicleID(playerid);
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
       GetVehicleModel(vehicleid);
       if(vehicleid == 431)
       {
          GetPlayerSpeed(playerid,true);
          if(GetPlayerSpeed(playerid,true) > 60)
          {
             GameTextForPlayer(playerid,"A bomb has been planted on your bus,don't slow down below 50mph or you'll be blowed up",7500,4);
             if(PRESSED(KEY_BRAKE/REVERSE))
             {
                GetPlayerSpeed(playerid,true);
                if(GetPlayerSpeed(playerid,true) < 50)
                {
                   SetVehicleHealth(vehicleid,0);
                   SendClientMessage(playerid,RED,"BYE BYE!!!");
                }
             }
          }
       }
     }
    return 1;
}
Compiling error: Undefined symbol newkeys explain this to me Stigg


Re: Can you tell me what's the problem? - Stigg - 20.04.2011

Because your command is supposed to go under:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
Not:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)



Re: Can you tell me what's the problem? - Cjgogo - 20.04.2011

good thanks now the only error is KEY_BRAKE/REVERSE also tried KEY_BRAKE(becasue I saw on GetVehicleVelocity tutorial a statement KEY_HANDBRAKE),so what's the problem(error is undefined symbol key_brake)