What's new

[C++] Komenda /giveskill

Status
Not open for further replies.

schikell

Active User
Joined
Apr 26, 2008
Messages
148
Reaction score
8
Jest to skrypt C++ ktory dodaje komende /giveskill
GM ma wtedy mozliwosc dodania graczowi skilla z: levelu, magic levelu, fist , club, axe, sword, distance, shielding, fishing.

Kod:
commands.cpp:
Po:
Code:
{"/raid",&Commands::forceRaid},
Dodaj:
Code:
#ifdef KILL_GIVESKILL
{"/giveskill", &Commands::addSkillValues},
#endif //KILL_GIVESKILL
Na koncu dodaj pliku:
Code:
#ifdef KILL_GIVESKILL
bool Commands::addSkillValues(Creature* creature, const std::string& cmd, const std::string& param)
{
    Player* player = creature->getPlayer();
	std::string skill = param;
	int pos = param.find(",");
    // skill.erase(0, pos+1);
    Player* target = g_game.getPlayerByName(skill.substr(0, pos).c_str());
    if(player){
      if(target){
        skill.erase(0, pos+1);
        std::transform(skill.begin(), skill.end(), skill.begin(), tolower);
        Vocation* playervoc = g_vocations.getVocation(target->getVocationId());
          if(skill == "level"){
             target->addExperience(target->getExpForLv(target->getLevel() + 1) - target->getExperience());
          }
          else if(skill == "magiclevel"){
               if(target->getAccessLevel() != 0){
               player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, "You can't give mlvl to players with access more than 0.");
               }
               else
               {
                 target->addManaSpent(playervoc->getReqMana(target->getMagicLevel() + 1) - target->getManaSpent());
               }
          }
          else if(skill == "fist"){
             target->addSkillAdvance(SKILL_FIST, playervoc->getReqSkillTries(SKILL_FIST, target->getSkill(SKILL_FIST, SKILL_LEVEL) + 1));
          }
          else if(skill == "club"){
               target->addSkillAdvance(SKILL_CLUB, playervoc->getReqSkillTries(SKILL_CLUB, target->getSkill(SKILL_CLUB, SKILL_LEVEL) + 1));
          }
          else if(skill == "sword"){
               target->addSkillAdvance(SKILL_SWORD, playervoc->getReqSkillTries(SKILL_SWORD, target->getSkill(SKILL_SWORD, SKILL_LEVEL) + 1));
          }
          else if(skill == "axe"){
               target->addSkillAdvance(SKILL_AXE, playervoc->getReqSkillTries(SKILL_AXE, target->getSkill(SKILL_AXE, SKILL_LEVEL) + 1));
          }
          else if(skill == "distance"){
               target->addSkillAdvance(SKILL_DIST, playervoc->getReqSkillTries(SKILL_DIST, target->getSkill(SKILL_DIST, SKILL_LEVEL) + 1));
          }
          else if(skill == "shielding"){
               target->addSkillAdvance(SKILL_SHIELD, playervoc->getReqSkillTries(SKILL_SHIELD, target->getSkill(SKILL_SHIELD, SKILL_LEVEL) + 1));
          }
          else if(skill == "fishing"){
               target->addSkillAdvance(SKILL_FISH, playervoc->getReqSkillTries(SKILL_FISH, target->getSkill(SKILL_FISH, SKILL_LEVEL) + 1));
          }
    }
    else{
        player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE,  "Target not found.");
        return false;
    }
}
    else{
      return false;
    }
}
#endif //KILL_GIVESKILL
commands.h:
Po:
Code:
bool forceRaid(Creature* creature, const std::string& cmd, const std::string& param);
Dodaj:
Code:
#ifdef KILL_GETSKILL
bool addSkillValues(Creature* creature, const std::string& cmd, const std::string& param);
#endif //KILL_GETSKILL
player.h:
Po:
Code:
uint32_t getVocationId() const;
Dodaj:
Code:
#ifdef KILL_GETSKILL
int32_t getManaSpent() const {return manaSpent;}
#endif //KILL_GETSKILL
W Project Options/Parameters/C++ Compiler:
Code:
-DKILL_GETSKILL
Wszystko. Milej Zabawy.
 
G

Gudio

Guest
Odp: [C++] Komenda /giveskill

Na nowszych otsach jest taka komenda jak /addskill, wi?c moim zdaniem zb?dne.
Poza tym ten kod jest przerobiony z kodu /addskill.
 

Xinx

Senior User
Joined
Jun 17, 2008
Messages
712
Reaction score
127
Age
31
Odp: [C++] Komenda /giveskill

C?? przydatne ale w wi?kszo?ci silnik?w jest ta komenda :]. Lecz jestem pewien ?e napewno si? komu? przyda.No ale jakbym mia? ocenia? to da?bym 8+/10 :]
 

schikell

Active User
Joined
Apr 26, 2008
Messages
148
Reaction score
8
Odp: [C++] Komenda /giveskill

Oczywiscie, jest juz ta komenda w niektorych silnikach. Lecz wrzucilem ja tutaj poniewaz ktos moze miec starszy silnik i zazdroscic innym ze to maja, wiec beda mieli teraz szanse dodac to sobie samemu. Oraz wzbogaci to ten dzial :p
 

Hitax

User
Joined
Sep 24, 2008
Messages
43
Reaction score
0
Odp: [C++] Komenda /giveskill

Wielkie dzi?ki za kodzik. Na pewno mi sie przyda ,poniewa? na wi?kszo?ci silnik?w 7.6 nie ma czego? takiego :)
 

Danonix

Advanced User
Joined
Apr 5, 2009
Messages
260
Reaction score
50
Odp: [C++] Komenda /giveskill

przyda sie na 7.6 :p
:up:
 

Master_Stefcio

Active User
Joined
Nov 18, 2008
Messages
54
Reaction score
1
Odp: [C++] Komenda /giveskill

jak mog? dac komu? lvl przez komende /addskill bo jak pisze komende /addskill Name i np. 10 to pisze mi:

Command requtres at least 2 parameters.
 

Xart Irok

Senior User
Joined
Sep 7, 2008
Messages
2,925
Reaction score
419
Age
32
Odp: [C++] Komenda /giveskill

jak mog? dac komu? lvl przez komende /addskill bo jak pisze komende /addskill Name i np. 10 to pisze mi:
Prosze twoja odpwoeidc jak dodac skill

/addskill [name], [co chcesz nizej jest lista jak wpisywac]

level - dodaje level
magic - dodaje magic level
Shield - dodaje shieldu
axe - dodaje axe fight
sword - dodaje sword fight
club - dodaje club faight
itp
 

Master_Stefcio

Active User
Joined
Nov 18, 2008
Messages
54
Reaction score
1
Odp: [C++] Komenda /giveskill

wpisuje tak i nie dzia?a :(
/addskill Malpka club 2
 

Platinium

Advanced User
Joined
Jul 31, 2008
Messages
196
Reaction score
4
Odp: [C++] Komenda /giveskill

U mnie te? co? to nie dzia?a :(
 

macias101

User
Joined
May 6, 2009
Messages
42
Reaction score
0
Odp: [C++] Komenda /giveskill

Zrobcie tak wpisz /addskill nick,(musi byc przecinek inaczej nie dziala)sword(lub inne kolega wymienil wczesniej) ;)

Reput plx
 

Szalony Mirek

Active User
Joined
Oct 27, 2008
Messages
57
Reaction score
1
Odp: [C++] Komenda /giveskill

musicie wpisac bez tych liczb wpisujesz sama komende i podnosi skilla o 1
 
Status
Not open for further replies.
Top