• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Lua Function] [0.3.6] doPlayerAddGesiorPoints(cid, points) and doPlayerAddZnotePoints(cid, points)

Mummrik

Hey!
Joined
Oct 22, 2007
Messages
707
Solutions
28
Reaction score
126
Location
Sweden
Two Lua functions to add premium points for Znote and Gesior AAC shop
Developed for tfs 0.3.6

For Gesior AAC
Lua:
function doPlayerAddGesiorPoints(cid, points)
   return db.executeQuery("UPDATE accounts SET premium_points = premium_points + "..points.." WHERE id = "..getAccountIdByName(getCreatureName(cid)).."") and doPlayerSave(cid)
end

For Znote AAC
Lua:
function doPlayerAddZnotePoints(cid, points)
   return db.executeQuery("UPDATE znote_accounts SET points = points + "..points.." WHERE account_id = "..getAccountIdByName(getCreatureName(cid)).."") and doPlayerSave(cid)
end
 
Last edited:
Not the wisest idea to add points directly in the database as it could be easily exploited with rollbacks.

Let's say I have a quest that gives x points but I use a storage to make sure the player doesn't get the points 2 times. If the server crashes the player will rollback, so he will be able to do the quest again but the points are going to still be there.

You should probably save the player after adding it to fix this :p
 
Not the wisest idea to add points directly in the database as it could be easily exploited with rollbacks.

Let's say I have a quest that gives x points but I use a storage to make sure the player doesn't get the points 2 times. If the server crashes the player will rollback, so he will be able to do the quest again but the points are going to still be there.

You should probably save the player after adding it to fix this :p

Do you know if it exist a function to save a player? something like this doPlayerSave(cid)

edit:
else something like this should work
Lua:
function doPlayerAddZnotePoints(cid, points)
   return db.executeQuery("UPDATE znote_accounts SET points = points + "..points.." WHERE account_id = "..getAccountIdByName(getCreatureName(cid)).."") and doPlayerSave(cid)
end

edit2: Seems like doPlayerSave(cid) exist on 0.3.6 so i will update the main post whit the changes, that would take care of the rollback issue. thanks for pointing it out

Edit3: seems like my method didnt work out as i tought since the player wont be saved. not sure if its the doPlayerSave(cid) that is broken or its impossible to return db.executeQuery(query) and doPlayerSave(cid)
I did test it whit an npc that give points.
Atleast the player position wont be saved, but i think the player is not saved at all.
 
Last edited:
Do you know if it exist a function to save a player? something like this doPlayerSave(cid)

edit:
else something like this should work
Lua:
function doPlayerAddZnotePoints(cid, points)
   return db.executeQuery("UPDATE znote_accounts SET points = points + "..points.." WHERE account_id = "..getAccountIdByName(getCreatureName(cid)).."") and doPlayerSave(cid)
end

edit2: Seems like doPlayerSave(cid) exist on 0.3.6 so i will update the main post whit the changes, that would take care of the rollback issue. thanks for pointing it out

Edit3: seems like my method didnt work out as i tought since the player wont be saved. not sure if its the doPlayerSave(cid) that is broken or its impossible to return db.executeQuery(query) and doPlayerSave(cid)
I did test it whit an npc that give points.
Atleast the player position wont be saved, but i think the player is not saved at all.
Place it before the return and it should work.

For TFS 1.x there is player:save()
 
Place it before the return and it should work.

For TFS 1.x there is player:save()
Still didnt work, well as i said earlier the position of the player didnt save. I mean i login move the player run the lua function and close the server to replicate a server crash, start it back up and login.
The player login at the same posistion it had before i run the lua function.
Im not sure what the doPlayerSave() function save's, if it save all the items it carry, storage's, depotitems and more. but dont keep track of the player position.
Or it might just be broken since there is a doSaveServer() function, and Elf didnt bother to fix the separate player save. (I dont want the function to save the whole server, due to lag spike it would cause for all players online)

I wont bother to test this further, since i wont use this function myself, i'll leave that up to someone that really need this function. (this function was an request on the support board, and i got it to work somewhat even if it can be exploited. During a server crash.)
 
Back
Top