Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This line is the equivalent of new PlayerInfo[MAX_PLAYERS][pInfo]
- local playerData = {};
- function onPlayerConnect(playerid) {
- // however, in PAWN the variables used in playerData are declared before intializing the variable
- // in Squirrel, the variables are declared (or created) when we are adding a new row
- playerData[playerid] <- {}; // this creates the new row
- playerData[playerid].money <- 500; // this is an example field
- // note that I use <- instead of playerData[playerid].500.
- // the <- symbolizes the adding of a new field, but once the field is created you access it like
- // playerData[playerid].money = 10;
- }
- addEvent("playerConnect", onPlayerConnect);
- function onPlayerDisconnect(playerid) {
- // when the player disconnects, we want to remove the information about them that was stored serverside
- delete playerData[playerid];
- }
- addEvent("playerDisconnect", onPlayerDisconnect);
Add Comment
Please, Sign In to add comment