Jump to content
MakeWebGames

Recommended Posts

Posted

Here are a list of useful functions that I've used. You might find them useful as well.

Please add your own sanitize/security functions where you see fit.

- This function checks if the user has a specific item in their inventory. It will return true if they do and false if they don't. Requires you to enter in the users ID, the item ID and the quantity of items you want to check.

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

- This function will return the name of the city that the user is currently in. Requires you to input the users location ID from the users table.

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

- This function will return a suffix of "s" if the qty entered is more than one. This is useful when you are displaying how much of a certain item a player has earned.

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

- This function will return time formatted so that it shows how much time has passed from the inputted time until the current time (similar to how time is shown on facebook or twitter posts). Requires you to input the unformatted Unix time. I grabbed this code from a development blog and modified it to suit my needs. After 7 days, the time will show the formatted date instead of the "how long ago" format.

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Posted

at a glance, the first function will only be true if it matches the specified quantity, a small fix will return true if the user has the item no matter the quantity. and a small redraw to use less code! untested but should work!

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Posted
at a glance, the first function will only be true if it matches the specified quantity, a small fix will return true if the user has the item no matter the quantity. and a small redraw to use less code! untested but should work!

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

That was the point. There are many instances where I would require users to have more than 1 of that item, and thus need to check accordingly. If you just had the function check only for 1, then you are limiting yourself. However, you could also modify the function call to have function item_have($user, $item, $qty=1) [~EDITED~], which will look for 1 item by default.

Thank you to all for the input.

Posted

May be helpful to some however it will need to be edited to work with MCCodes/your preferences, but here is something I took out of an unfinished project based on an idea I saw done by SilviaTungDevil on DeadLand.

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Posted
@DJK funny... i had something similar made on the same site

Explain? :huh:

Okay here's another one however I cannot take credit for it as Spudinski created it but I find it to be a similar approach to your Time function Diesl.

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...