• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ anyone can edit this cod for me

Elgenady

Veteran OT User
Joined
Aug 5, 2011
Messages
1,637
Solutions
35
Reaction score
351
i have this cod
Code:
if(target && target->getPlayer())

        {

            std::string tmp = "0";

            target->getPlayer()->getStorage("17025", tmp);

            if(tmp == "1")

                damage = (int32_t)std::ceil(damage/2);

            else if(tmp == "1")

                damage = 0;

        }
need change this cod to be like this
Code:
if(target && target->getPlayer())

        {

            std::string tmp = "0";

            target->getPlayer()->getStorage("17025", tmp);

            if(tmp == "1")

                damage = (int32_t)std::ceil(damage * tmp / 100);

            else if(tmp == "1")

                damage = 0;

        }
im use tfs 0.4
 
Solution
std::stoi - is a C++11 function and he probably use some old source which expects C++98 while ignoring C++11 entirely that's why he have this error + if you use std::stoi you should check for exceptions otherwise you can get crash.
You can use C function atoi to do the conversion string -> int(whatever the reason is for this because you already check if tmp is "1").
i have this cod
Code:
if(target && target->getPlayer())

        {

            std::string tmp = "0";

            target->getPlayer()->getStorage("17025", tmp);

            if(tmp == "1")

                damage = (int32_t)std::ceil(damage/2);

            else if(tmp == "1")

                damage = 0;

        }
need change this cod to be like this
Code:
if(target && target->getPlayer())

        {

            std::string tmp = "0";

            target->getPlayer()->getStorage("17025", tmp);

            if(tmp == "1")

                damage = (int32_t)std::ceil(damage * tmp / 100);

            else if(tmp == "1")

                damage = 0;

        }
im use tfs 0.4
Code:
if(target && target->getPlayer())

        {

            std::string tmp = "0";

            target->getPlayer()->getStorage("17025", tmp);

            if(tmp == "1")

                damage = (int32_t)std::ceil(damage * std::stoi(tmp) / 100);

            else if(tmp == "1")

                damage = 0;

        }
 
Code:
if(target && target->getPlayer())

        {

            std::string tmp = "0";

            target->getPlayer()->getStorage("17025", tmp);

            if(tmp == "1")

                damage = (int32_t)std::ceil(damage * std::stoi(tmp) / 100);

            else if(tmp == "1")

                damage = 0;

        }
error
game.cpp `stoi' is not a member of `std'
 
C++:
#include <iostream>
#include <string>

int main()
{
  std::string daysInAYear = "365";
  std::cout << "Days in a year: " << std::stoi(daysInAYear);
}
Code:
Days in a year: 365
when compile give me this error :S
`stoi' is not a member of `std'
 
std::stoi - is a C++11 function and he probably use some old source which expects C++98 while ignoring C++11 entirely that's why he have this error + if you use std::stoi you should check for exceptions otherwise you can get crash.
You can use C function atoi to do the conversion string -> int(whatever the reason is for this because you already check if tmp is "1").
 
Solution
std::stoi - is a C++11 function and he probably use some old source which expects C++98 while ignoring C++11 entirely that's why he have this error + if you use std::stoi you should check for exceptions otherwise you can get crash.
You can use C function atoi to do the conversion string -> int(whatever the reason is for this because you already check if tmp is "1").
i did like u said its always give me this error

std::string' to `const char*' for argument `1' to `int atoi(const char*)
 
Back
Top