22.04.2012, 22:31
I want to make a level system but i can't My Scripting skills are so poor...
I have the script for leveling here it is:
Credits: jameskmonger
The progress bar (textdraw) - i want the experience and level system to show in progress bar here is the code:
Source and Credits: Kitten - https://sampforum.blast.hk/showthread.php?tid=185774
Pics from the textdraw:
The one who will help me will earn 3 Reputation points (my friends profiles :P)
I have the script for leveling here it is:
Код:
new experiences = { 50, 400, 800, 1200, 1600, 2000 }; new experience[MAX_PLAYERS], level[MAX_PLAYERS]; public OnGameModeInit() { SetTimer("MakeExp", 60000, true); // A timer that repeats every minute, which gives 1+ exp return 1; } forward MakeExp(); public MakeExp() { foreach (Player, i) { experience[i] ++; SetPlayerScore(i, level[i]); if(level[i] > sizeof(experiences)) return 1; if(experience[i] >= experiences[level[i]]) { level[i]++; } } return 1; }
The progress bar (textdraw) - i want the experience and level system to show in progress bar here is the code:
Код:
#include <a_samp> new Text:BoxWhite; new Text:Bar[MAX_PLAYERS]; new Text:EXP[MAX_PLAYERS]; forward UpdateTextDraw(playerid); public OnFilterScriptInit() { BoxWhite = TextDrawCreate(230.000000, 392.000000, "~n~"); TextDrawBackgroundColor(BoxWhite, 255); TextDrawFont(BoxWhite, 1); TextDrawLetterSize(BoxWhite, 0.500000, 1.000000); TextDrawColor(BoxWhite, -1); TextDrawSetOutline(BoxWhite, 0); TextDrawSetProportional(BoxWhite, 1); TextDrawSetShadow(BoxWhite, 1); TextDrawUseBox(BoxWhite, 1); TextDrawBoxColor(BoxWhite, -1); TextDrawTextSize(BoxWhite, 430.000000, -612.000000); for(new playerid = 0; playerid < MAX_PLAYERS; playerid++) { Bar[playerid] = TextDrawCreate(230.000000, 392.000000, "~n~"); TextDrawBackgroundColor(Bar[playerid], 255); TextDrawFont(Bar[playerid], 1); TextDrawLetterSize(Bar[playerid], 0.359999, 1.000000); TextDrawColor(Bar[playerid], -1); TextDrawSetOutline(Bar[playerid], 0); TextDrawSetProportional(Bar[playerid], 1); TextDrawSetShadow(Bar[playerid], 1); TextDrawUseBox(Bar[playerid], 1); TextDrawBoxColor(Bar[playerid], 16777215); TextDrawTextSize(Bar[playerid], 225.000000, 0.000000); EXP[playerid] = TextDrawCreate(281.000000, 392.000000, "~b~EXP: 0/~g~50"); TextDrawBackgroundColor(EXP[playerid], 255); TextDrawFont(EXP[playerid], 1); TextDrawLetterSize(EXP[playerid], 0.500000, 1.000000); TextDrawColor(EXP[playerid], -1); TextDrawSetOutline(EXP[playerid], 0); TextDrawSetProportional(EXP[playerid], 1); TextDrawSetShadow(EXP[playerid], 1); } return 1; } public OnFilterScriptExit() { TextDrawHideForAll(BoxWhite); TextDrawDestroy(BoxWhite); for(new playerid = 0; playerid < MAX_PLAYERS; playerid++) { TextDrawHideForAll(Bar[playerid]); TextDrawDestroy(Bar[playerid]); TextDrawHideForAll(EXP[playerid]); TextDrawDestroy(EXP[playerid]); } return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/testbar", cmdtext, true, 10) == 0) { TextDrawTextSize(Bar[playerid],229.0000, 0.000000 ); UpdateTextDraw(playerid); return 1; } if (strcmp("/testbar2", cmdtext, true, 10) == 0) { UpdateTextDraw(playerid); TextDrawTextSize(Bar[playerid],265.0000, 0.000000 ); TextDrawSetString(EXP[playerid],"~b~EXP: 8/50"); return 1; } return 0; } public OnPlayerDeath(playerid, killerid, reason) { new string[64]; new score = GetPlayerScore(killerid); SetPlayerScore(killerid, score+1); format(string, sizeof(string),"~b~EXP: %d/~g~50",score+1); TextDrawSetString(EXP[killerid],string); GivePlayerMoney(killerid, 6000); // +6000$ switch(score) { case 0: { TextDrawTextSize(Bar[playerid],229.0000, 0.000000 ); UpdateTextDraw(playerid); } // goes up by 5 and 4 :) case 1: { TextDrawTextSize(Bar[playerid],233.0000, 0.000000 ); UpdateTextDraw(playerid); } case 2: { TextDrawTextSize(Bar[playerid],236.0000, 0.000000 ); UpdateTextDraw(playerid); } case 3: { TextDrawTextSize(Bar[playerid],240.0000, 0.000000 ); UpdateTextDraw(playerid); } case 4: { TextDrawTextSize(Bar[playerid],245.0000, 0.000000 ); UpdateTextDraw(playerid); } case 5: { TextDrawTextSize(Bar[playerid],250.0000, 0.000000 ); UpdateTextDraw(playerid); } case 6: { TextDrawTextSize(Bar[playerid],255.0000, 0.000000 ); UpdateTextDraw(playerid); } case 7: { TextDrawTextSize(Bar[playerid],260.0000, 0.000000 ); UpdateTextDraw(playerid); } case 8: { TextDrawTextSize(Bar[playerid],265.0000, 0.000000 ); UpdateTextDraw(playerid); } case 9: { TextDrawTextSize(Bar[playerid],270.0000, 0.000000 ); UpdateTextDraw(playerid); } case 10: { TextDrawTextSize(Bar[playerid],275.0000, 0.000000 ); UpdateTextDraw(playerid); } case 11: { TextDrawTextSize(Bar[playerid],280.0000, 0.000000 ); UpdateTextDraw(playerid); } case 12: { TextDrawTextSize(Bar[playerid],285.0000, 0.000000 ); UpdateTextDraw(playerid); } case 13: { TextDrawTextSize(Bar[playerid],290.0000, 0.000000 ); UpdateTextDraw(playerid); } case 14: { TextDrawTextSize(Bar[playerid],295.0000, 0.000000 ); UpdateTextDraw(playerid); } case 15: { TextDrawTextSize(Bar[playerid],300.0000, 0.000000 ); UpdateTextDraw(playerid); } case 16: { TextDrawTextSize(Bar[playerid],305.0000, 0.000000 ); UpdateTextDraw(playerid); } case 17: { TextDrawTextSize(Bar[playerid],310.0000, 0.000000 ); UpdateTextDraw(playerid); } case 18: { TextDrawTextSize(Bar[playerid],315.0000, 0.000000 ); UpdateTextDraw(playerid); } case 19: { TextDrawTextSize(Bar[playerid],320.0000, 0.000000 ); UpdateTextDraw(playerid); } case 20: { TextDrawTextSize(Bar[playerid],325.0000, 0.000000 ); UpdateTextDraw(playerid); } case 21: { TextDrawTextSize(Bar[playerid],330.0000, 0.000000 ); UpdateTextDraw(playerid); } case 22: { TextDrawTextSize(Bar[playerid],340.0000, 0.000000 ); UpdateTextDraw(playerid); } case 23: { TextDrawTextSize(Bar[playerid],345.0000, 0.000000 ); UpdateTextDraw(playerid); } case 24: { TextDrawTextSize(Bar[playerid],350.0000, 0.000000 ); UpdateTextDraw(playerid); } case 25: { TextDrawTextSize(Bar[playerid],355.0000, 0.000000 ); UpdateTextDraw(playerid); } case 26: { TextDrawTextSize(Bar[playerid],360.0000, 0.000000 ); UpdateTextDraw(playerid); } case 27: { TextDrawTextSize(Bar[playerid],365.0000, 0.000000 ); UpdateTextDraw(playerid); } case 28: { TextDrawTextSize(Bar[playerid],370.0000, 0.000000 ); UpdateTextDraw(playerid); } case 29: { TextDrawTextSize(Bar[playerid],375.0000, 0.000000 ); UpdateTextDraw(playerid); } case 30: { TextDrawTextSize(Bar[playerid],380.0000, 0.000000 ); UpdateTextDraw(playerid); } case 31: { TextDrawTextSize(Bar[playerid],385.0000, 0.000000 ); UpdateTextDraw(playerid); } case 32: { TextDrawTextSize(Bar[playerid],390.0000, 0.000000 ); UpdateTextDraw(playerid); } case 33: { TextDrawTextSize(Bar[playerid],395.0000, 0.000000 ); UpdateTextDraw(playerid); } case 34: { TextDrawTextSize(Bar[playerid],400.0000, 0.000000 ); UpdateTextDraw(playerid); } case 35: { TextDrawTextSize(Bar[playerid],405.0000, 0.000000 ); UpdateTextDraw(playerid); } case 36: { TextDrawTextSize(Bar[playerid],410.0000, 0.000000 ); UpdateTextDraw(playerid); } case 37: { TextDrawTextSize(Bar[playerid],415.0000, 0.000000 ); UpdateTextDraw(playerid); } case 38: { TextDrawTextSize(Bar[playerid],420.0000, 0.000000 ); UpdateTextDraw(playerid); } case 39: { TextDrawTextSize(Bar[playerid],425.0000, 0.000000 ); UpdateTextDraw(playerid); } case 40: { TextDrawTextSize(Bar[playerid],430.0000, 0.000000 ); UpdateTextDraw(playerid); } case 41: { TextDrawTextSize(Bar[playerid],435.0000, 0.000000 ); UpdateTextDraw(playerid); } case 42: { TextDrawTextSize(Bar[playerid],440.0000, 0.000000 ); UpdateTextDraw(playerid); } case 43: { TextDrawTextSize(Bar[playerid],445.0000, 0.000000 ); UpdateTextDraw(playerid); } case 44: { TextDrawTextSize(Bar[playerid],450.0000, 0.000000 ); UpdateTextDraw(playerid); } case 45: { TextDrawTextSize(Bar[playerid],455.0000, 0.000000 ); UpdateTextDraw(playerid); } case 46: { TextDrawTextSize(Bar[playerid],460.0000, 0.000000 ); UpdateTextDraw(playerid); } case 47: { TextDrawTextSize(Bar[playerid],465.0000, 0.000000 ); UpdateTextDraw(playerid); } case 48: { TextDrawTextSize(Bar[playerid],470.0000, 0.000000 ); UpdateTextDraw(playerid); } case 49: { TextDrawTextSize(Bar[playerid],475.0000, 0.000000 ); UpdateTextDraw(playerid); } } return 1; } public UpdateTextDraw(playerid) { TextDrawHideForPlayer(playerid,Bar[playerid]); TextDrawShowForPlayer(playerid,Bar[playerid]); return 1; } public OnPlayerConnect(playerid) { TextDrawShowForPlayer(playerid, BoxWhite); TextDrawShowForPlayer(playerid, Bar[playerid]); TextDrawShowForPlayer(playerid, EXP[playerid]); return 1; }
Pics from the textdraw:
The one who will help me will earn 3 Reputation points (my friends profiles :P)