Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- event onLoad(){
- // nonQuery as we are creating a table
- database.nonQuery("CREATE TABLE IF NOT EXISTS playerstats(
- id VARCHAR(17) PRIMARY KEY,
- zombiesKilled INT NOT NULL DEFAULT 0,
- megaZombiesKilled INT NOT NULL DEFAULT 0
- );");
- }
- event onPlayerJoined(player){
- // nonquery as we are inserting data
- // @p0 acts as a placeholder, which the first argument is then passed into
- database.nonQuery("INSERT IGNORE INTO playerstats (id, zombiesKilled, megaZombiesKilled) VALUES ('@p0', 0, 0);", player.id);
- }
- event onZombieKilled(player){
- // nonQuery as we are updating data, and not reading it
- database.nonQuery("UPDATE playerstats SET zombiesKilled = zombiesKilled + 1 WHERE id = '@p0';", player.id);
- }
- event onMegaZombieKilled(player){
- // nonquery as we are inserting data
- database.nonQuery("UPDATE playerstats SET megaZombiesKilled = megaZombiesKilled + 1 WHERE id = '@p0';", player.id);
- }
- command zombiekills(){
- permission = "zombiekills";
- allowedCaller = "player";
- execute(){
- // firstRow as we only want to fetch one row of data for that player.
- data = database.firstRow("Select * FROM playerstats WHERE id = '@p0';", player.id);
- if(data.count == 0) return; // return if the data does not exist for some reason to prevent errors.
- // message the player the info, the placeholders {0} and {1} are replaced with data[1] and data[2]
- player.message("Zombies Killed: {0}\nMegas Killed: {1}".format(data[1], data[2]));
- }
- }
Add Comment
Please, Sign In to add comment