Guest User

Untitled

a guest
Sep 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. // This line is the equivalent of new PlayerInfo[MAX_PLAYERS][pInfo]
  2. local playerData = {};
  3.  
  4. function onPlayerConnect(playerid) {
  5.     // however, in PAWN the variables used in playerData are declared before intializing the variable
  6.     // in Squirrel, the variables are declared (or created) when we are adding a new row
  7.    
  8.     playerData[playerid] <- {}; // this creates the new row
  9.     playerData[playerid].money <- 500; // this is an example field
  10.    
  11.     // note that I use <- instead of playerData[playerid].500.
  12.     // the <- symbolizes the adding of a new field, but once the field is created you access it like
  13.     // playerData[playerid].money = 10;
  14. }
  15. addEvent("playerConnect", onPlayerConnect);
  16.  
  17. function onPlayerDisconnect(playerid) {
  18.     // when the player disconnects, we want to remove the information about them that was stored serverside
  19.     delete playerData[playerid];
  20. }
  21. addEvent("playerDisconnect", onPlayerDisconnect);
Add Comment
Please, Sign In to add comment