• Страница 1 из 1
  • 1
[Урок] Навык стрельбы
Дмитрий Дата: Понедельник, 05.11.2012, 17:43 | Сообщение # 1 | Сообщить о нерабочей теме


Аватар для Дмитрий

Команда показывающая навык вашей стрельбы
Скажу сразу идея не моя
Автор: 9GYAR (составлял с нуля)

в new PlayerInfo[MAX_PLAYERS][pInfo];
добавим переменные

Code
pColt,  
     pDesert,  
     pSmg,  
     pAk,  
     pM4,  


далее в веху мода где все паблики начинаются добавим

Code
forward SetPlayerSkills(playerid);  
public SetPlayerSkills(playerid)  
{  
SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, PlayerInfo[playerid][pColt]);  
SetPlayerSkillLevel(playerid, WEAPONSKILL_DESERT_EAGLE, PlayerInfo[playerid][pDesert]);  
SetPlayerSkillLevel(playerid, WEAPONSKILL_MP5, PlayerInfo[playerid][pSmg]);  
SetPlayerSkillLevel(playerid, WEAPONSKILL_AK47, PlayerInfo[playerid][pAk]);  
SetPlayerSkillLevel(playerid, WEAPONSKILL_M4, PlayerInfo[playerid][pM4]);  
return 1;  
}  


в паблик OnPlayerDisconnect ставим
Code
SetPlayerSkills(playerid);  


в паблин public OnPlayerDeath добавим

Code
if(reason == 22) { if(PlayerInfo[killerid][pColt] >= 0 && PlayerInfo[killerid][pColt] <= 1000) { PlayerInfo[killerid][pColt] += 2; SetPlayerSkills(killerid); } }  
       
if(reason == 24) { if(PlayerInfo[killerid][pDesert] >= 0 && PlayerInfo[killerid][pDesert] <= 1000) { PlayerInfo[killerid][pDesert] += 2; SetPlayerSkills(killerid); } }  
       
if(reason == 29) { if(PlayerInfo[killerid][pSmg] >= 0 && PlayerInfo[killerid][pSmg] <= 1000) { PlayerInfo[killerid][pSmg] += 2; SetPlayerSkills(killerid); } }  
       
if(reason == 30) { if(PlayerInfo[killerid][pAk] >= 0 && PlayerInfo[killerid][pAk] <= 1000) { PlayerInfo[killerid][pAk] += 2; SetPlayerSkills(killerid); } }  
       
if(reason == 31) { if(PlayerInfo[killerid][pM4] >= 0 && PlayerInfo[killerid][pM4] <= 1000) { PlayerInfo[killerid][pM4] += 2; SetPlayerSkills(killerid); } }  


теперь перейдем в сохранение уровня стрельбы
в паблик добавляем OnPlayerRegister


Code
format(var, 64, "Pistol=%d\n",PlayerInfo[playerid][pColt]);fwrite(hFile, var);   
format(var, 64, "Desertl=%d\n",PlayerInfo[playerid][pDesert]);fwrite(hFile, var);   
format(var, 64, "SMG=%d\n",PlayerInfo[playerid][pSmg]);fwrite(hFile, var);   
format(var, 64, "AK47=%d\n",PlayerInfo[playerid][pAk]);fwrite(hFile, var);   
format(var, 64, "M4=%d\n",PlayerInfo[playerid][pM4]);fwrite(hFile, var);  


OnPlayerLogin
Code
if( strcmp( key , "Pistol" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pColt] = strval( val ); }   
if( strcmp( key , "Desert" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDesert] = strval( val ); }   
if( strcmp( key , "Smg" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pSmg] = strval( val ); }   
if( strcmp( key , "Ak47" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAk] = strval( val ); }   
if( strcmp( key , "M4" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pM4] = strval( val ); }  

OnPlayerLogin
Code
SetPlayerSkills(playerid);  


OnPlayerConnect
Code
PlayerInfo[playerid][pColt] = 0;    
PlayerInfo[playerid][pDesert] = 0;   
PlayerInfo[playerid][pSmg] = 0;   
PlayerInfo[playerid][pAk] = 0;   
PlayerInfo[playerid][pM4] = 0;


а теперь поставим наш уровень стрельбы в статистику персонажа
public ShowStats

Code
new ptxt[20], dtxt[20],smtxt[20], sktxt[20],s4txt[20];   
if(PlayerInfo[playerid][pColt] >= 0 && PlayerInfo[playerid][pColt] <= 99) ptxt = "0 Уровень";   
else if(PlayerInfo[playerid][pColt] >= 100 && PlayerInfo[playerid][pColt] <= 199) ptxt = "1 Уровень";   
else if(PlayerInfo[playerid][pColt] >= 200 && PlayerInfo[playerid][pColt] <= 299) ptxt = "2 Уровень";   
else if(PlayerInfo[playerid][pColt] >= 300 && PlayerInfo[playerid][pColt] <= 399) ptxt = "3 Уровень";   
else if(PlayerInfo[playerid][pColt] >= 400) ptxt = "4 Уровень";    
if(PlayerInfo[playerid][pDesert] >= 0 && PlayerInfo[playerid][pDesert] <= 099) dtxt = "0 Уровень";   
else if(PlayerInfo[playerid][pDesert] >= 100 && PlayerInfo[playerid][pDesert] <= 199) dtxt = "1 Уровень";   
else if(PlayerInfo[playerid][pDesert] >= 200 && PlayerInfo[playerid][pDesert] <= 299) dtxt = "2 Уровень";   
else if(PlayerInfo[playerid][pDesert] >= 300 && PlayerInfo[playerid][pDesert] <= 399) dtxt = "3 Уровень";   
else if(PlayerInfo[playerid][pDesert] >= 400) dtxt = "4 Уровень";    
if(PlayerInfo[playerid][pSmg] >= 0 && PlayerInfo[playerid][pSmg] <= 99) smtxt = "0 Уровень";   
else if(PlayerInfo[playerid][pSmg] >= 100 && PlayerInfo[playerid][pSmg] <= 199) smtxt = "1 Уровень";   
else if(PlayerInfo[playerid][pSmg] >= 200 && PlayerInfo[playerid][pSmg] <= 299) smtxt = "2 Уровень";   
else if(PlayerInfo[playerid][pSmg] >= 300 && PlayerInfo[playerid][pSmg] <= 399) smtxt = "3 Уровень";   
else if(PlayerInfo[playerid][pSmg] >= 400) smtxt = "4 Уровень";   
if(PlayerInfo[playerid][pAk] >= 0 && PlayerInfo[playerid][pAk] <= 99) sktxt = "0 Уровень";   
else if(PlayerInfo[playerid][pAk] >= 100 && PlayerInfo[playerid][pAk] <= 199) sktxt = "1 Уровень";   
else if(PlayerInfo[playerid][pAk] >= 200 && PlayerInfo[playerid][pAk] <= 299) sktxt = "2 Уровень";   
else if(PlayerInfo[playerid][pAk] >= 300 && PlayerInfo[playerid][pAk] <= 399) sktxt = "3 Уровень";   
else if(PlayerInfo[playerid][pAk] >= 400) sktxt = "4 Уровень"; }   
if(PlayerInfo[playerid][pM4] >= 0 && PlayerInfo[playerid][pM4] <= 99) s4txt = "0 Уровень";   
else if(PlayerInfo[playerid][pM4] >= 100 && PlayerInfo[playerid][pM4] <= 199) s4txt = "1 Уровень";   
else if(PlayerInfo[playerid][pM4] >= 200 && PlayerInfo[playerid][pM4] <= 299) s4txt = "2 Уровень";   
else if(PlayerInfo[playerid][pM4] >= 300 && PlayerInfo[playerid][pM4] <= 399) s4txt = "3 Уровень";   
else if(PlayerInfo[playerid][pM4] >= 400) s4txt = "4 Уровень";   
format(string, sizeof(string), "Colt:[%s]\nDeagle:[%s]\nMP5:[%s]\nM4:[%s]\nAK-47:[%s]", ptxt,dtxt, smtxt, sktxt, s4txt);  


Вот и все!


From Russia With Love!
  • Страница 1 из 1
  • 1
Поиск: