String IP Problem -
Byrner - 04.03.2009
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.
Re: String IP Problem -
Marcel - 04.03.2009
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.
Re: String IP Problem -
Byrner - 04.03.2009
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");
Re: String IP Problem -
Marcel - 04.03.2009
As you're using a string now you should replace
with
in the format with unbanip.
pawn Код:
format(strMsg, sizeof(strMsg), "unbanip %s",IP);
Re: String IP Problem -
Byrner - 04.03.2009
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. :/
Re: String IP Problem -
Marcel - 04.03.2009
It can, with a string you always define a size, with an integer you just do
with a string you always have
or so.
Re: String IP Problem -
Byrner - 04.03.2009
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.
Re: String IP Problem -
Marcel - 04.03.2009
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.
Re: String IP Problem -
Nimphious - 04.03.2009
Quote:
Originally Posted by Marcel
As you're using a string now you should replace with in the format with unbanip.
pawn Код:
format(strMsg, sizeof(strMsg), "unbanip %s",IP);
|
why use
That will only do letters not numbers.
Re: String IP Problem -
Byrner - 04.03.2009
I tried using
Just gives me two errors, I tried searching SA-MP forum for it, no luck.