Jump to content

Как вычесть деньги у одного и передать другому?


Recommended Posts

А точнее - как вычесть деньги у взявшего пикап и передать водителю?

function onDoctorMode ( theVehicle, seat, jacked ) 
    if ( getElementModel ( theVehicle ) == 416 ) then -- доктормобиль 
        outputChatBox("[+] Now You Are Doctor [+]", source, 255, 0, 0, true) 
        bindKey ( source, "lshift", "down", createFirstAid ) 
        bindKey ( source, "lctrl", "down", clearMemoryFA ) 
        --bindKey ( source, "rshift", "down", forDriverFA ) 
        driverDoctor = getVehicleOccupant ( theVehicle ) 
    end 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), onDoctorMode ) 
  
function offDoctorMode ( theVehicle, seat, jacked ) 
    if ( getElementModel ( theVehicle ) == 416 ) then -- доктормобиль 
        outputChatBox("[x] Now You're not a doctor [x]", source, 91, 127, 0, true) 
        unbindKey ( source, "lshift", "down", createFirstAid ) 
        unbindKey ( source, "lctrl", "down", clearMemoryFA ) 
        --unbindKey ( source, "rshift", "down", forDriverFA ) 
        destroyElement(firstAid) 
        destroyElement(docCar_x) 
        destroyElement(docCar_y) 
        destroyElement(docCar_z) 
        destroyElement(driverDoctor) 
    end 
end 
addEventHandler ( "onPlayerVehicleExit", getRootElement(), offDoctorMode ) 
  
function createFirstAid (thePlayer) 
destroyElement(firstAid) 
destroyElement(docCar_x) 
destroyElement(docCar_y) 
destroyElement(docCar_z) 
docCar_x, docCar_y, docCar_z = getElementPosition(thePlayer) 
firstAid = createPickup ( docCar_x, docCar_y, docCar_z, 0, 100, 10000 ) 
if(isPickupSpawned(firstAid))then 
outputChatBox("*Pickup created", source, 128, 128, 128, true) 
setTimer ( clearMemoryFA, 5000, 1) 
else 
outputChatBox("*Pickup not created", source, 128, 128, 128, true) 
end 
end 
  
function clearMemoryFA () 
if(isPickupSpawned(firstAid))then 
destroyElement(firstAid) 
destroyElement(docCar_x) 
destroyElement(docCar_y) 
destroyElement(docCar_z) 
outputChatBox("*Pickup destroyed", source, 128, 128, 128, true) 
else 
outputChatBox("*Pickup not present", source, 128, 128, 128, true) 
end 
end 
  
function pickupTakenFA ( player ) 
   givePlayerMoney ( player, -100) --берет у подобравшего плату 
   givePlayerMoney ( driverDoctor, 100) --дает водителю-доктору 
   outputChatBox("*bought first aid kit for $ 100", player, 128, 128, 128, true) 
   outputChatBox("*sold first aid kit for $ 100", source, 128, 128, 128, true) 
end 
addEventHandler ( "onPickupHit", firstAid, pickupTakenFA ) 
  

Link to comment

Прочитай подробнее про https://wiki.multitheftauto.com/wiki/BindKey

Первый аргумент должен содержать элемент - player. А так же, по-моему, агрументы, которые есть у тебя - нет в bindKey.

А так же, вместо переменных типа, driverDoctor, docCar_x и т.д. используй таблицы, т.к. если два игрока сядут в два докторских автомобиля, данная переменная будет содержать инфу о том, кто последний сел в автомобиль.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...