KEY_YES
#1

PHP код:
if ((newkeys==KEY_YES))
    {    
        if(
IsWorking[playerid] == && PlayerData[playerid][Job] == 3) {
            new 
car GetClosestVehicle(playerid);
            if(!
IsPlayerNearVehicle(playeridcar10) && !IsABoat(car)) return 1;                        
            if(
VJob[playerid] != car) return SCM(playeridCOLOR_WHITE""COLOR_JOB_EMBED"(Job)"COLOR_WHITE_EMBED" You are not near the garbage truck.");
            if(
IsPlayerInAnyVehicle(playerid)) return SCM(playeridCOLOR_WHITE""COLOR_JOB_EMBED"(Job)"COLOR_WHITE_EMBED" You can`t pick up the rubbish if you are in the car.");
            if(!
PlayerToPoint(15.0playeridGunoiSet[playerid][0], GunoiSet[playerid][1], GunoiSet[playerid][2])) return SCM(playeridCOLOR_WHITE""COLOR_JOB_EMBED"(Job)"COLOR_WHITE_EMBED" You are not near the garbage bin");
            
TickGarbage[playerid] = gettime();
            if(
IsCarrying[playerid] == 0)
            {
                
DisablePlayerCheckpoint(playerid);
                
SetPlayerSpecialAction(playeridSPECIAL_ACTION_CARRY);
                
SetPlayerAttachedObject(playerid6122010.2998220.663485, -0.036337184.31135590.0040890.0000001.0000001.0000001.000000 );
                
IsCarrying[playerid] = 1;
                
SCM(playeridCOLOR_WHITE""COLOR_JOB_EMBED"(Job)"COLOR_WHITE_EMBED" Throw the rubbish into the back of the garbage truck");
            }
            if(
IsCarrying[playerid] == 1)
            {
                if(
gettime() - TickGarbage[playerid] <3) return 0;     
                
IsCarrying[playerid] = 0;
                
SetPlayerSpecialAction(playerid0);
                
RemovePlayerAttachedObject(playerid6);
                new 
randn random(sizeof(GarbageCP));
                
SetPlayerCheckpoint(playeridGarbageCP[randn][0], GarbageCP[randn][1], GarbageCP[randn][2], 4.0);
                
SetCoordGunoi(playeridGarbageCP[randn][0], GarbageCP[randn][1], GarbageCP[randn][2]);
                
SCM(playeridCOLOR_WHITE"Go to next CP");
                new 
Float:coord[3];
                
GetPlayerPos(playeridcoord[0], coord[1], coord[2]);
                
SetDestination(playeridcoord[0], coord[1], coord[2]);
                
PGarbageCP[playerid] += 1;
                
UpdateJobBox(playerid);
            }
            
            
        }
    } 
the problem is,the first time you press Y,it works( you get the bag in your hand and animation ),but when you try to press Y again ( to throw garbage in truck and remove animations,it simply doesn`t work )

i debugged all the coordinates and i am where i should be..
Reply
#2

If you looked at the wiki, you'd see this is specifically how you DON'T check for a key...

https://sampwiki.blast.hk/wiki/OnPlayerK...heck_for_a_key

Quote:

This code may even work in your testing, but it is wrong and your testing is insufficient. Try crouching and pressing fire - your code will instantly stop working. Why? Because "newkeys" is no longer the same as "KEY_FIRE", it is the same as "KEY_FIRE" COMBINED WITH "KEY_CROUCH".

Reply
#3

changed to
PHP код:
if ((newkeys KEY_YES)) 
still only the first press works.
Reply
#4

Then you've got other issues, but first off, fact is you were checking the keypress wrong, so chances are your code has more flaws.

If you're not within 10 feet of the vehicle, then it won't actually 'return' any information, so at that range, it will likely look like the command is doing nothing, but it could be doing what it should do.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)