Feelay 0 Report post Posted February 18, 2008 Hey! I know I am asking alot. But much is happening theese days.Sorry if I disturb with my questions.The thing I am trying to do is:Ex. If the user becomes level 2, he should get 5 skill points. I can't do this: if($userlevel=5){mysql_query("UPDATE user SET skillpoints =$points+5");}because then it would update everytime the code was loaded. I hope you understand what I am trying to do. If not, tell me and i'll try to explain better.Thanks //Feelay Share this post Link to post Share on other sites
PerHapsYouSeen 0 Report post Posted February 19, 2008 (edited) why dont't you add a column to store the last time he was got skill points. Isn't is much easier. Edited February 19, 2008 by PerHapsYouSeen (see edit history) Share this post Link to post Share on other sites
iGuest 3 Report post Posted February 19, 2008 Hey Feelay,All I noticed is the common mistake with doing comparisons. if($userlevel = 5)is not the same as if($userlevel == 5) The first one is an assignment which means you'll make $userlevel become 5 and will result in true.The second one will not solve the issue though, you really need to do something that PerhapsYouSeen has suggested and add a column to record that they have gotten their points, then you just need to check that first before you give them points.Cheers,MC Share this post Link to post Share on other sites
Feelay 0 Report post Posted February 19, 2008 sorry but I don't understand Share this post Link to post Share on other sites
yordan 10 Report post Posted February 19, 2008 sorry but I don't understand He was explaining that your code does not test that the userlevel is 5.Your code is forcing userlevel to be level 5, which is probably not what you want. Share this post Link to post Share on other sites
Feelay 0 Report post Posted February 19, 2008 (edited) Oh. but my code was just an example.I just wanted to show, that if I wrote that code, it would give the user 5 skill points every time the page was loaded. but I want it to give the user 5 skill points, only the moment the user reach level 5 (for ex.).and between, I thougt of making a colum for the points, but the user will be able to "buy" health and strenght and stuff for theese points. so they (the points) will become 0 anyway =S Edited February 19, 2008 by Feelay (see edit history) Share this post Link to post Share on other sites
pyost 0 Report post Posted February 19, 2008 You have a script that increases a player's level if a condition is fulfilled, right? So why not just increase the points at the sime time you increase his/hers level? Share this post Link to post Share on other sites
Feelay 0 Report post Posted February 19, 2008 because the script says:If the user exp is more than 100, the user level should be changed to level 2 (etc.).. And that script runs everytime the user login. It would not work. Share this post Link to post Share on other sites
yordan 10 Report post Posted February 19, 2008 OK, it seems that you definitively need a user status column in a table. With a value like "3065" if the user is at level 3 and has 65 lifehalth points. Or value 4100 if level 4 with 100 points. You change this value only once (when he goes to level 5) and you read the value each time the player logs in. Share this post Link to post Share on other sites
pyost 0 Report post Posted February 19, 2008 because the script says: If the user exp is more than 100, the user level should be changed to level 2 (etc.).. And that script runs everytime the user login. It would not work. Why not "If the user exp is more than 100, the user level should be changed to level 2, and the user should get skill points (etc.).."? Share this post Link to post Share on other sites
PerHapsYouSeen 0 Report post Posted February 20, 2008 I don't know why my suggestion can not slove Feelay's problem ?I make a column name 'last_received_points' which stores the last time he was received the bonus (supposing $last_received_points holds the last lever he was received bonus skillpoints)then I combine with his lever, so it would exactly update just in once time if ($user_level==5 and $last_received_points<5) {update skillpoints;} if the user"buy" health and strenght and stuff for theese pointsI think it does not effect the last time he received bonus (or you can update it indepently if the user done sth above... if you want) Share this post Link to post Share on other sites