11.11.2013, 15:32
Hola, primero de todo crearemos 2 variables, una almacenara el nivel del jugador y otra el timer para desactivar la burbuja y definiremos el callback "DesactivarBurbuja":
Luego en el callback OnPlayerConnect setearemos el nivel del jugador y su respectivo rango (ES IMPORTANTE QUE PONGAS ESTO LUEGO DE CARGAR LOS DATOS DEL JUGADOR):
Y en el callback OnPlayerDeath almacenaremos el nivel del jugador, le setearemos su nivel y rango y luego si el nivel del jugador almacenado es menor al seteado entonces el jugador subio de nivel:
Por ъltimo creamos el callback que serб llamado por el timer cuando el jugador suba de nivel, este desactivara la burbuja:
Ojala que te sirva, adaptalo a tu cуdigo, y por cierto, intenta no hacer copy paste y si no entender que hace cada cosa, la wiki de sa-mp te puede servir y hay muchos otros tutoriales por este foro sobre pawn, saludos!
PD: No lo he probado..
pawn Код:
forward DesactivarBurbuja(playerid);
new Nivel[MAX_PLAYERS], TimerNivel[MAX_PLAYERS];
pawn Код:
public OnPlayerConnect(playerid)
{
new rango[24];
if((PlayerInfo[playerid][Kills]>= 0 && PlayerInfo[playerid][Kills] <= 30)) { rango = "NOBATO"; Nivel[playerid] = 1; }
else if((PlayerInfo[playerid][Kills]>= 31 && PlayerInfo[playerid][Kills] <= 74)) { rango = "APRENDIZ"; Nivel[playerid] = 2; }
else if((PlayerInfo[playerid][Kills]>= 75 && PlayerInfo[playerid][Kills] <= 129)) { rango = "BASICO"; Nivel[playerid] = 3; }
else if((PlayerInfo[playerid][Kills]>= 130 && PlayerInfo[playerid][Kills] <= 179)) { rango = "AVANZADO"; Nivel[playerid] = 4; }
else if((PlayerInfo[playerid][Kills]>= 180 && PlayerInfo[playerid][Kills] <= 250)) { rango = "INTERMEDIO"; Nivel[playerid] = 5; }
else if((PlayerInfo[playerid][Kills]>= 251 && PlayerInfo[playerid][Kills] <= 330)) { rango = "GANSTER"; Nivel[playerid] = 6; }
else if((PlayerInfo[playerid][Kills]>= 331 && PlayerInfo[playerid][Kills] <= 422)) { rango = "SICARIO"; Nivel[playerid] = 7; }
else if((PlayerInfo[playerid][Kills]>= 423 && PlayerInfo[playerid][Kills] <= 49) { rango = "PROFESIONAL"; Nivel[playerid] = 8; }
else if((PlayerInfo[playerid][Kills]>= 499 && PlayerInfo[playerid][Kills] <= 679)) { rango = "CAPO"; Nivel[playerid] = 9; }
else if((PlayerInfo[playerid][Kills]>= 680 && PlayerInfo[playerid][Kills] <= 880)) { rango = "ASPIRANTE A PRO"; Nivel[playerid] = 10; }
else if((PlayerInfo[playerid][Kills]>= 881 && PlayerInfo[playerid][Kills] <= 977)) { rango = "PRO"; Nivel[playerid] = 11; }
else if((PlayerInfo[playerid][Kills]>= 978 && PlayerInfo[playerid][Kills] <= 1195)) { rango = "PRO GAMER"; Nivel[playerid] = 12; }
else if((PlayerInfo[playerid][Kills]>= 1196 && PlayerInfo[playerid][Kills] <= 1410)) { rango = "SUPER PRO"; Nivel[playerid] = 13; }
else if((PlayerInfo[playerid][Kills]>= 1411 && PlayerInfo[playerid][Kills] <= 1930)) { rango = "IMPARABLE"; Nivel[playerid] = 14; }
else if((PlayerInfo[playerid][Kills]>= 1931 && PlayerInfo[playerid][Kills] <= 2487)) { rango = "PRO MATADOR"; Nivel[playerid] = 15; }
else if((PlayerInfo[playerid][Kills]>= 2488 && PlayerInfo[playerid][Kills] <= 4650)) { rango = "SUPER MATADOR"; Nivel[playerid] = 16; }
else if((PlayerInfo[playerid][Kills]>= 4651 && PlayerInfo[playerid][Kills] <= 40850)) { rango = "SUPER GAMER PRO"; Nivel[playerid] = 17; }
return 1;
}
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new rango[24], NivelViejo[MAX_PLAYERS] = Nivel[killerid];
if((PlayerInfo[killerid][Kills]>= 0 && PlayerInfo[killerid][Kills] <= 30)) { rango = "NOBATO"; Nivel[killerid] = 1; }
else if((PlayerInfo[killerid][Kills]>= 31 && PlayerInfo[killerid][Kills] <= 74)) { rango = "APRENDIZ"; Nivel[killerid] = 2; }
else if((PlayerInfo[killerid][Kills]>= 75 && PlayerInfo[killerid][Kills] <= 129)) { rango = "BASICO"; Nivel[killerid] = 3; }
else if((PlayerInfo[killerid][Kills]>= 130 && PlayerInfo[killerid][Kills] <= 179)) { rango = "AVANZADO"; Nivel[killerid] = 4; }
else if((PlayerInfo[killerid][Kills]>= 180 && PlayerInfo[killerid][Kills] <= 250)) { rango = "INTERMEDIO"; Nivel[killerid] = 5; }
else if((PlayerInfo[killerid][Kills]>= 251 && PlayerInfo[killerid][Kills] <= 330)) { rango = "GANSTER"; Nivel[killerid] = 6; }
else if((PlayerInfo[killerid][Kills]>= 331 && PlayerInfo[killerid][Kills] <= 422)) { rango = "SICARIO"; Nivel[killerid] = 7; }
else if((PlayerInfo[killerid][Kills]>= 423 && PlayerInfo[killerid][Kills] <= 49) { rango = "PROFESIONAL"; Nivel[killerid] = 8; }
else if((PlayerInfo[killerid][Kills]>= 499 && PlayerInfo[killerid][Kills] <= 679)) { rango = "CAPO"; Nivel[killerid] = 9; }
else if((PlayerInfo[killerid][Kills]>= 680 && PlayerInfo[killerid][Kills] <= 880)) { rango = "ASPIRANTE A PRO"; Nivel[killerid] = 10; }
else if((PlayerInfo[killerid][Kills]>= 881 && PlayerInfo[killerid][Kills] <= 977)) { rango = "PRO"; Nivel[killerid] = 11; }
else if((PlayerInfo[killerid][Kills]>= 978 && PlayerInfo[killerid][Kills] <= 1195)) { rango = "PRO GAMER"; Nivel[killerid] = 12; }
else if((PlayerInfo[killerid][Kills]>= 1196 && PlayerInfo[killerid][Kills] <= 1410)) { rango = "SUPER PRO"; Nivel[killerid] = 13; }
else if((PlayerInfo[killerid][Kills]>= 1411 && PlayerInfo[killerid][Kills] <= 1930)) { rango = "IMPARABLE"; Nivel[killerid] = 14; }
else if((PlayerInfo[killerid][Kills]>= 1931 && PlayerInfo[killerid][Kills] <= 2487)) { rango = "PRO MATADOR"; Nivel[killerid] = 15; }
else if((PlayerInfo[killerid][Kills]>= 2488 && PlayerInfo[killerid][Kills] <= 4650)) { rango = "SUPER MATADOR"; Nivel[killerid] = 16; }
else if((PlayerInfo[killerid][Kills]>= 4651 && PlayerInfo[killerid][Kills] <= 40850)) { rango = "SUPER GAMER PRO"; Nivel[killerid] = 17; }
if(NivelViejo[killerid] < Nivel[killerid])
{
SetPlayerHealth(killerid, 100);
SetPlayerArmour(killerid, 100);
SendClientMessage(killerid, -1, "Felicidades, ЎSubiste de nivel!");
SetPlayerAttachedObject(killerid,9,1276,1,-0.241000,0.056999,0.000000,2.200000,71.799964,-101.999992,0.000000,0.000000,0.051999);
TimerNivel[killerid] = SetTimerEx("DesactivarBurbuja", 3000, false, "i", killerid) // Desactivar burbuja al jugador dentro de 3 segundos
}
return 1;
}
pawn Код:
public DesactivarBurbuja(playerid)
{
RemovePlayerAttachedObject(playerid, 9) ;
KillTimer(TimerNivel[playerid]);
}
Ojala que te sirva, adaptalo a tu cуdigo, y por cierto, intenta no hacer copy paste y si no entender que hace cada cosa, la wiki de sa-mp te puede servir y hay muchos otros tutoriales por este foro sobre pawn, saludos!
PD: No lo he probado..