String IP Problem
#1

Ok, I made it so a players IP saves to his player file.
I am making a !unban command for IRC.
It wasn't working, so I did a debug to see what was happening.
Turns out it's only doing "unbanip (First 2 digits of IP, and stopping after full stop)

For example, if the IP I was unbanning was
73.56.321.56

It would send the rcon command "unbanip 73"

I was told this could be to do with a string problem.
I have tried a few, but they didn't work, any recommendations?
Or anybody know of another solution?

Here's part of my code:
pawn Код:
new strMsg[10];
  new IP = dUserINT(params).("PlayersIP");
  format(strMsg, sizeof(strMsg), "unbanip %d",IP);
  SendRconCommand(strMsg);
  ircSay(conn,channel,strMsg);
I have it echo to IRC for debug purposes, obviously.
Reply
#2

You're using
pawn Код:
new ID = dUserINT(params).("PlayersIP");
You should use
pawn Код:
new IP[15] = dUserINT(params).("PlayersIP");
Otherwise it will only get the first 2 values because a . is not valid integer. PS: I use 15 for the size because an IP cannot be bigger than this.
Reply
#3

Thanks, but this gives me the following error:
Код:
(6133) : error 008: must be a constant expression; assumed zero
My code now:
pawn Код:
new strMsg[10];
 new IP[15] = dUserINT(params).("PlayersIP");
 format(strMsg, sizeof(strMsg), "unbanip %d",IP);
 SendRconCommand(strMsg);
 ircSay(conn,channel,strMsg);
Edit:
Line 6133 is:
pawn Код:
new IP[15] = dUserINT(params).("PlayersIP");
Reply
#4

As you're using a string now you should replace
pawn Код:
%d
with
pawn Код:
%s
in the format with unbanip.
pawn Код:
format(strMsg, sizeof(strMsg), "unbanip %s",IP);
Reply
#5

Ok, but I doubt this is what was giving me the error, as the script can usually not tell whether it should be %s or %d.

Edit:
Yeah, the same error. :/
Reply
#6

It can, with a string you always define a size, with an integer you just do
pawn Код:
new integer;
with a string you always have
pawn Код:
new string[15];
or so.
Reply
#7

I mean, in the format, it dosen't give an error, if you're using the wrong one. (%s or %d).
As proven just now; as I only get the same error as before.
Reply
#8

Yes, I see now we are using dUserINT, we have to get a string, I don't know much about DINI and DUTILS. So find out the function yourself and replace this:
pawn Код:
new IP[15] = dUserINT(params).("PlayersIP");
with
pawn Код:
new IP[15] = dUserSTR(params).("PlayersIP");
Where dUserSTR should be the function that gets a string from the player file.
Reply
#9

Quote:
Originally Posted by Marcel
As you're using a string now you should replace
pawn Код:
%d
with
pawn Код:
%s
in the format with unbanip.
pawn Код:
format(strMsg, sizeof(strMsg), "unbanip %s",IP);
why use

pawn Код:
%s
That will only do letters not numbers.
Reply
#10

I tried using
pawn Код:
dUserSTR
Just gives me two errors, I tried searching SA-MP forum for it, no luck.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)