Help converting OnPlayerPickUpDynamicPickup to OnPlayerKeyStateChange - 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)
+--- Thread: Help converting OnPlayerPickUpDynamicPickup to OnPlayerKeyStateChange (
/showthread.php?tid=604401)
Help converting OnPlayerPickUpDynamicPickup to OnPlayerKeyStateChange -
FunnyBear - 04.04.2016
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
Re: Help converting OnPlayerPickUpDynamicPickup to OnPlayerKeyStateChange -
Dignity - 04.04.2016
Very basic example:
PHP код:
public OnPlayerKeyStateChange ( playerid, newkeys, oldkeys ) {
if ( newkeys & KEY_SECONDARY_ATTACK ) {
// Change the three 00.00's to your entrance point's coordinates
if ( IsPlayerInRangeOfPoint ( playerid, 5.0, 00.00, 00.00, 00.00 ) ) {
// SetPlayerPos ...
// etc etc
}
// Change these 00.00's to your exit point's coordinates ...
else if ( IsPlayerInRangeOfPoint ( playerid, 5.0, 00.00, 00.00, 00.00 ) ) {
// SetPlayerPos ...
// etc etc
}
}
return true ;
}
https://sampwiki.blast.hk/wiki/Keys
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
Re: Help converting OnPlayerPickUpDynamicPickup to OnPlayerKeyStateChange -
FunnyBear - 04.04.2016
I have worked this out myself, there's no need to worry.