Help converting OnPlayerPickUpDynamicPickup to OnPlayerKeyStateChange
#1

Hello there,

I currently have a shop system and I would like to change it so instead of having to walk into the pickup to enter the store, you could press the [F] button to enter it.

My current code is

Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
    new arr[2];
    Streamer_GetArrayData(STREAMER_TYPE_PICKUP, pickupid, E_STREAMER_EXTRA_ID, arr);
    if(arr[0] == ENEX_STREAMER_IDENTIFIER)
    {
        if((gettime() - DelayTick[playerid]) < 3)
            return 1;

        if(pickupid == storeData[arr[1]][entCP])
        {
            DelayTick[playerid] = gettime();

            SetPlayerVirtualWorld(playerid, storeData[arr[1]][virtualID]);
            SetPlayerInterior(playerid, storeData[arr[1]][interiorID]);

            SetPlayerPos(playerid, storeData[arr[1]][extPos][0], storeData[arr[1]][extPos][1], storeData[arr[1]][extPos][2]);
            SetPlayerFacingAngle(playerid, storeData[arr[1]][extPos][3]);
            SetCameraBehindPlayer(playerid);
        }
        if(pickupid == storeData[arr[1]][extCP])
        {
            DelayTick[playerid] = gettime();

            SetPlayerInterior(playerid, 0);
            SetPlayerVirtualWorld(playerid, 0);

            SetPlayerPos(playerid, storeData[arr[1]][entPos][0], storeData[arr[1]][entPos][1], storeData[arr[1]][entPos][2]);
            SetPlayerFacingAngle(playerid, storeData[arr[1]][entPos][3]);
            SetCameraBehindPlayer(playerid);
        }
    }
	return true;
}
Help would be appreciated
Reply
#2

Very basic example:

PHP код:
public OnPlayerKeyStateChange playeridnewkeysoldkeys ) {
    if ( 
newkeys KEY_SECONDARY_ATTACK ) {
    
        
// Change the three 00.00's to your entrance point's coordinates
        
if ( IsPlayerInRangeOfPoint playerid5.000.0000.0000.00 ) ) {
        
            
// SetPlayerPos ...
            // etc etc
        
}
        
        
// Change these 00.00's to your exit point's coordinates ...
        
else if ( IsPlayerInRangeOfPoint playerid5.000.0000.0000.00 ) ) {
            
// SetPlayerPos ...
            // etc etc
        
}
        
    }
    return 
true ;

https://sampwiki.blast.hk/wiki/Keys
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
Reply
#3

I have worked this out myself, there's no need to worry.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)