[MT]Tobi Posted March 20, 2008 Share Posted March 20, 2008 (edited) HI, need script! When i am a taxi driver and drive with my taxi and another people get in car, he must pay 100$ or so! What schould I do ? How must I scripting it that the driver is earning the money???? Edited March 20, 2008 by Guest Link to comment
Morelli Posted March 20, 2008 Share Posted March 20, 2008 (edited) TaxiVehicles = { [420]=true, [438]=true } --[[ Made by Morelli]]-- function PayPlayerOnEnter( theVehicle ) local seat = getPlayerOccupiedVehicleSeat ( source ) if ( (TaxiVehicles[getVehicleID(theVehicle)]) and ( not (seat == 0) ) ) then local money = getPlayerMoney(source) if (money > 99) then local driver = getVehicleOccupant ( theVehicle, 0 ) takePlayerMoney ( source, 100 ) givePlayerMoney ( driver, 100 ) outputChatBox( "You paid the $100 fare, to the driver, for using the taxi.", source) else outputChatBox( "You don't have enough money to pay the taxi driver!", source) removePlayerFromVehicle ( source ) end end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), PayPlayerOnEnter) Edited March 20, 2008 by Guest Link to comment
[MT]Tobi Posted March 20, 2008 Author Share Posted March 20, 2008 (edited) ... Edited March 21, 2008 by Guest Link to comment
Morelli Posted March 20, 2008 Share Posted March 20, 2008 (edited) Check 2nd post. Edited March 20, 2008 by Guest Link to comment
[MT]Tobi Posted March 20, 2008 Author Share Posted March 20, 2008 sry, but i doesn`t work again ^^, whats wrong? Link to comment
Morelli Posted March 20, 2008 Share Posted March 20, 2008 (edited) Check 2nd post. Edited March 20, 2008 by Guest Link to comment
[MT]Tobi Posted March 20, 2008 Author Share Posted March 20, 2008 yes thx, and what can I do that the driver gets the money, which the other hab payed? Link to comment
Morelli Posted March 20, 2008 Share Posted March 20, 2008 Check the second post in this thread. I updated the code. Link to comment
[MT]Tobi Posted March 20, 2008 Author Share Posted March 20, 2008 great and how to get the money only when i am a taxi driver which the skin ID 14 ? Link to comment
Morelli Posted March 20, 2008 Share Posted March 20, 2008 You'll need this check: local driverskin = getPlayerSkin ( driver ) if ( not driverskin == 14 ) then ... else ... end So, all in all, this should be the complete code: TaxiVehicles = { [420]=true, [438]=true } -- Define what vehicles are taxis. In this case, it's the vehicle ID's 420 and 438. --[[ Made by Morelli]]-- function PayPlayerOnEnter( theVehicle ) -- Create a function which imports the 'theVehicle' from onPlayerVehicleEnter local seat = getPlayerOccupiedVehicleSeat ( source ) -- Find out which seat the person who entered the vehicle is now sitting in. if ( (TaxiVehicles[getVehicleID(theVehicle)]) and ( not (seat == 0) ) ) then -- Find out if the player is not in the driver seat, but in a taxi. local money = getPlayerMoney(source) -- Return a variable value called 'money', which shows how much cash the passenger. if (money > 99) then -- If the passenger has more than (or equal to) 100 dollars, then continue. local driver = getVehicleOccupant ( theVehicle, 0 ) -- Find out the name of the driver of the taxi. local driverskin = getPlayerSkin ( driver ) -- Find out the skin of the taxi driver and name it the variable 'driverskin'. if ( not (driverskin == 14) ) then -- If the driver's skin does not equal to 14... outputChatBox( "The person driving this taxi isn't a registered taxi driver! You haven't paid them.", source) -- Tell the passenger that they haven't paid the driver. else -- Otherwise, if the driver does have skin ID 14.. takePlayerMoney ( source, 100 ) -- Take $100 from the passenger givePlayerMoney ( driver, 100 ) -- Give $100 to the driver outputChatBox( "You paid the $100 fare, to the driver, for using the taxi.", source) -- Tell the passenger that they paid the driver. end else -- If the passenger has 99 or less dollars outputChatBox( "You don't have enough money to pay the taxi driver!", source) -- Tell them they don't have enough money removePlayerFromVehicle ( source ) -- Remove them from the vehicle end end end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), PayPlayerOnEnter) -- Define when we want this function to be triggered. I've added some comments to make it more user-friendly for those trying to learn. Link to comment
[MT]Tobi Posted March 21, 2008 Author Share Posted March 21, 2008 thx, in the server window he wrotes Warning: Bad argument @ 'getplayerskin` - Line 1 and 23 is that okay or any problem? Link to comment
Morelli Posted March 21, 2008 Share Posted March 21, 2008 thx, in the server window he wrotes Warning: Bad argument @ 'getplayerskin` - Line 1 and 23is that okay or any problem? Are you testing it with another player? If you aren't then it's not so much a problem because the script is trying to firstly get the name of the person who is in the driver seat (when there isn't one), then they are trying to crunch this non-existant name and pull out a skin ID number to correlate to it. Link to comment
[MT]Tobi Posted March 21, 2008 Author Share Posted March 21, 2008 ok, all is going right i have only one question, how to make a script that a person whith the ID 50 can give other player health, when they get in car? they also must pay 100$ for these service Link to comment
50p Posted March 21, 2008 Share Posted March 21, 2008 Do the same think... but give them health. Do you know what wiki is? If you do why don't you use it? You will be proud of yourself if you make something yourself. setElementHealth Link to comment
Morelli Posted March 21, 2008 Share Posted March 21, 2008 ok, all is going right i have only one question, how to make a script that a person whith the ID 50 can give other player health, when they get in car? they also must pay 100$ for these service By ID, I assume you are reffering to skinID 50. Well, there are multiple ways to approach this, I'd suggest structuring it in the following way function FUNCTIONAME(sourcePlayer, command, target, price) local targetPlayer = getPlayerFromNick ( target ) if ( targetPlayer ) then if ( price ) then local sourceskin = getPlayerSkin ( sourcePlayer ) if ( not (sourceskin == 50) ) then else takePlayerMoney ( target, price ) givePlayerMoney ( sourcePlayer, price ) setElementHealth ( target, 100 ) end end end end addCommandHandler("CHANGEME", FUNCTIONAME) Using the command /changeme [targetplayername] [price] you can set the person's health to 100 and take some money off them. The person using the command must have skin ID 50. Just read up on the wiki and adjust it to your liking. Link to comment
[MT]Tobi Posted March 21, 2008 Author Share Posted March 21, 2008 yeah, how to scipt that he only type the command when he is sitting in a vehicle which is to repair? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now