Remove item get 1 donation point

vTune

KakelmästareN^
Joined
Jun 14, 2012
Messages
3,675
Best answers
0
Reaction score
375
Location
Sweden
Hello OtLand,

I'm requesting a fairly easy script(Im just a noobtard).

You click on a item and it gives u 1 donation point. (Also the item should be removed ofc).

I've tried to script this and I could pase in the script as far as I've gotten but I dont think it would help anyone so I skip that part :p

Kind Regards
vTune
 

Danger II

FluppiX.com
Joined
Nov 21, 2012
Messages
1,597
Best answers
11
Reaction score
397
Location
Germany
Code:
function onUse(cid, item, frompos, item2, topos)
   doRemoveItem(item.uid, 1)
   doPlayerAddItem(cid, ITEM_ID_HERE, AMOUNT_HERE)
   doPlayerSendTextMessage(cid, 22, "Anytext here player will get for using this item")
end
Something like that? Not sure if you want to get donation point in SQL or w/e so..

If you want to add a donation point in SQL add this in global.lua or functions.lua in data-folder
Code:
function addPlayerDonationPoint(id, amount)
  db.executeQuery("UPDATE `players` SET `donation_point` = ".. amount .." WHERE `id` = ".. id .."")
end
(You will have to edit your query thats for sure...but that basicly how it would work)

in Actions folder:
Code:
function onUse(cid, item, frompos, item2, topos)
local GUID = getPlayerGUID(cid)
   doRemoveItem(item.uid, 1)
   addPlayerDonationPoint(GUID, 1)
   doPlayerSendTextMessage(cid, 22, "Anytext here player will get for using this item")
end
 
Last edited:
OP
vTune

vTune

KakelmästareN^
Joined
Jun 14, 2012
Messages
3,675
Best answers
0
Reaction score
375
Location
Sweden
@Last World

Thanks but I chose to do it like this instead

Code:
function onUse(cid, item, frompos, item2, topos)
local points = 1;
   doRemoveItem(item.uid, 1)
   db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid))

   doPlayerSendCancel(cid, "You received " .. points .. " point(s).")
   doPlayerSendTextMessage(cid, 22, "Anytext here player will get for using this item")
end
 

Danger II

FluppiX.com
Joined
Nov 21, 2012
Messages
1,597
Best answers
11
Reaction score
397
Location
Germany
If you do it via global.lua or functions.lua you can use addPlayerDonationPoint in every script :)
your choise

btw:
local points = 1

instead of

local points = 1;
 
Last edited:
Top