These are chat archives for ikkentim/SampSharp

25th
May 2015
S. Alexandre
@r00tKiller
May 25 2015 12:22
Hello
I have a problem
I have a class that extends GtaPlayer , this class has proprety, and i have to save them ( database ) when the player disconnects, but when the player disconnect and before my save code, these values are set to 0
Florian van Dillen
@fvandillen
May 25 2015 12:50
Hi there, could you show us the code you're using?
I have a seperate class called Account, which I use for saving player information
@ikkentim Hoe kan ik het beste een custom chat handler maken, zodat ik het standaard chatsystem vervang voor iets scripted. (In pawn deed ik dit door simpelweg return 0 te doen in OnPlayerText)
S. Alexandre
@r00tKiller
May 25 2015 13:00
I'm uploading the code on PasteBin
Here is my player class : http://pastebin.com/zyEafi4n
The game mode class
Florian van Dillen
@fvandillen
May 25 2015 14:29
Nice, let me take a look at it
I use this:
public class Player : GtaPlayer { /// <summary> /// Account object which is responsible for all persistent data of a player. /// </summary> public Account Account { get; set; }
Wait, let me use pastebin
My player class:
My Account class (which is actually a model because I use nHibernate for ORM): http://pastebin.com/8Vms8NS1
S. Alexandre
@r00tKiller
May 25 2015 15:38
So do you know why my code don't work ?
Florian van Dillen
@fvandillen
May 25 2015 15:39
AslPlayer aplayer = new AslPlayer(id);
Is this part of your SavePlayer()-method?
You shouldn't be doing new player, you need to reference the existing player in order to save its stats.
In OnPlayerDisconnected you should do `SaveUser(player); and in the SaveUser method, you need to use the player object as reference instead of the old code.
S. Alexandre
@r00tKiller
May 25 2015 15:44
Oww yeah
I'm sooooo idiot
it should be AslPayer aplayer = aPlayers[id];
I feel so idiot
Florian van Dillen
@fvandillen
May 25 2015 15:45
Nope
You dont need that code at all
You simply call SaveUser(player) and the query can be done
S. Alexandre
@r00tKiller
May 25 2015 15:47
Oww yeah
Thank you so much.
Florian van Dillen
@fvandillen
May 25 2015 15:51
Always welcome :)
S. Alexandre
@r00tKiller
May 25 2015 16:00
There is no tutorial on SampSharp right ? I mean avanced tutorials ? Not setup
Tim Potze
@ikkentim
May 25 2015 16:34
@r00tKiller Not yet; I want to but my free time is limited.
@fvandillen For every callback which handles return values there is an associated EventArgs class with a value which can change the return value. In the OnPlayerText event a TextEventArgs instance is given. It contains a bool SendToPlayers which is true by default, set it to false.
Florian van Dillen
@fvandillen
May 25 2015 22:58
@ikkentim thanks, exactly what i was looking for
@r00tKiller what i like is the fact that most of the advanced stuff isnt SAMP related. SAMP is just what the player sees:)