Moin,
undzwar hab ich diese Funktion gefunden aber leider zeigt sie mir nicht kein Pickup an.
Code
getDistanceToPickup(modelID) {
if (!updatePickups())
return -1
dist := -1
for i, o in oPickups {
if (o.MODELID == modelID) {
playerPos := GetPlayerCoordinates()
newDist := getDist([o.XPOS, o.YPOS, o.ZPOS], playerPos)
if (dist == -1 || newDist < dist) {
dist := newDist
}
}
}
return dist
}
updatePickups() {
if (!checkHandles())
return false
if (iRefreshPicks + iUpdateTickPicks > A_TickCount)
return true
oPickups := []
iRefreshPicks := A_TickCount
dwAddress := readDWORD(hGTA, readDWORD(hGTA, readDWORD(hGTA, dwSAMP + SAMP_INFO_OFFSET) + SAMP_PPOOLS_OFFSET) + 0x20)
if (ErrorLevel || !dwAddress)
return false
pickupCount := readDWORD(hGTA, dwAddress)
Loop, % 4096
{
i := A_Index - 1
pickupID := readMem(hGTA, dwAddress + i * 4 + 0x4004, 4, "Int")
if (pickupID < 0)
continue
pickupCount--
pickupModelID := readMem(hGTA, dwAddress + i * 0x14 + 0xF004, 4, "Int")
pickupType := readMem(hGTA, dwAddress + i * 0x14 + 0xF008, 4, "Int")
pickupX := readMem(hGTA, dwAddress + i * 0x14 + 0xF00C, 4 , "Float")
pickupY := readMem(hGTA, dwAddress + i * 0x14 + 0xF010, 4 , "Float")
pickupZ := readMem(hGTA, dwAddress + i * 0x14 + 0xF014, 4 , "Float")
oPickups.Push(Object("ID", pickupID, "MODELID", pickupModelID, "TYPE", pickupType, "XPOS", pickupX, "YPOS", pickupY, "ZPOS", pickupZ))
if (pickupCount <= 0)
break
}
return true
}
getClosestPickupModel() {
if (!updatePickups())
return -1
dist := -1
model := 0
for i, o in oPickups {
playerPos := GetPlayerCoordinates()
newDist := getDist([o.XPOS, o.YPOS, o.ZPOS], playerPos)
if (dist == -1 || newDist < dist) {
dist := newDist
model := o.MODELID
}
}
return model
}
Alles anzeigen
es wird bei getClosestPickupModel immer nur 0 geloggt.
Ich benutze die aktuellste SAMP-UDF ich denke dass es irgendwie falsch ausgelesen wird oder so..
Grüße Marschl