Posts: 33
Threads: 8
Joined: Dec 2016
Reputation:
0
Hey,
i have a command to give over money to another player.
But i want to return it to 1 , if the IP if playerid is the same as of pid (target).
But i dont know how to check if the IP is the same? I mean, it wont work with == ...
Can someone quickly write a code? Thanks.
Posts: 1,219
Threads: 51
Joined: Jul 2012
Posts: 570
Threads: 55
Joined: Oct 2016
Posts: 1,219
Threads: 51
Joined: Jul 2012
Quote:
Originally Posted by RyderX
No need to check ip to dis-allow yourself to send money to urself,
just use this one:
PHP код:
COMMAND:pay(playerid, params[])
{
new otherid, cash;
if (sscanf(params, "dd", otherid, cash)) SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}/pay [ID] [Amount]");
else
{
if(GetPlayerMoney(playerid) < cash) SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}You don't have that much!");
else if(!IsPlayerConnected(otherid)) SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}Invalid ID (Player not connected)");
else if(otherid == playerid) SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}Invalid ID (You can't pay yourself)");
else
{
GivePlayerMoney(playerid, -cash);
GivePlayerMoney(otherid, cash);
}
}
return 1;
}
|
Dude ... he doesn't to check if it the same player but another character of the same person ... so your answer makes no sense
Posts: 33
Threads: 8
Joined: Dec 2016
Reputation:
0
I dont understand it damn... read alot of times but i still dont get it, please can someone do it for me?
Posts: 570
Threads: 55
Joined: Oct 2016
PHP код:
COMMAND:pay(playerid, params[])
{
new otherid, cash;
if (sscanf(params, "dd", otherid, cash)) SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}/pay [ID] [Amount]");
else
{
if(GetPlayerMoney(playerid) < cash) SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}You don't have that much!");
else if(!IsPlayerConnected(otherid)) SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}Invalid ID (Player not connected)");
else if(otherid == playerid) SendClientMessage(playerid, COLOR_RED, "[ERROR]: {FFFFFF}Invalid ID (You can't pay yourself)");
else
{
GivePlayerMoney(playerid, -cash);
GivePlayerMoney(otherid, cash);
}
}
return 1;
}
Here it is
Posts: 1,219
Threads: 51
Joined: Jul 2012
very easy D;
PHP код:
if(!strcmp(ipOne, ipTwo, false))
{
print("IPs match.");
}
else
{
print("IPs don't match.");
}
RyderX are you a troll? You can't be serious, open your eyes!
Posts: 570
Threads: 55
Joined: Oct 2016
Quote:
Originally Posted by [Bios]Marcel
very easy D;
PHP код:
if(!strcmp(ipOne, ipTwo, false))
{
print("IPs match.");
}
else
{
print("IPs don't match.");
}
RyderX are you a troll? You can't be serious, open your eyes!
|
it's just 3:18AM im just like a drunk guy