Have you even added it to load and saving?
|
Hi,
I'm trying to set-up a command where I can promote people to VIP, and for some reason it doesn't seem to be working as expected.
Here's the code:
It doesn't seem to be saving in the profile correctly at all.Code:if (cmd[0].equals("vip") && p.rights >= 3) { String person = playerCommand.substring((playerCommand.indexOf(" ") + 1)); Player p2 = Engine.players[Engine.getIdFromName(person)]; if (p2 != null) { p.frames.sendMessage(p, "The following user " + p2.username + "has been promoted to VIP."); p2.frames.sendMessage(p2, "Thank you for purchasing Server VIP!"); p2.frames.sendMessage(p2, "Your exclusive VIP permissions have been activated. Enjoy."); p2.vip = 1; p2.updateReq = true; } }
This seems to be the same for the starter too, so I seem to be getting the starter everytime I login
Any help?
Thanks
Have you even added it to load and saving?
Yep.
andCode:else if (line.startsWith("vip:")) p.vip = Integer.parseInt(line.substring(7));
and I'm pretty sure it doing something since I can make myself VIP by using:Code:stream.writeString("vip:" + p.vip);
It's just that the command I'm using isn't functioning correctly.Code:if (p.username.equals("sometest")) { p.rights = 3; p.vip = 1; }
You're doing it wrong This number is incorrect..
p.vip = Integer.parseInt(line.substring(7));
Basically it is the amount of characters that you place inside else if (line.startsWith("vip:")), so it should be p.vip = Integer.parseInt(line.substring(4)); and not 7 I'm guessing your starter is the same so just check it.
should beCode:else if (line.startsWith("vip:")) p.vip = Integer.parseInt(line.substring(7));
That's probely why it won't save, cause you have 7 lines it should save it as but it only got 4 lines.Code:else if (line.startsWith("vip:")) p.vip = Integer.parseInt(line.substring(4));
Oh, I see, thanks guys - I'll keep that in mind in the future
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |