Help -
RedCode - 05.08.2015
Hi , I have a problem in this CMD , player can abuse that , for example /houselocker put sguns -111111
I need when player use amount under 0 cmd don't work
Код:
COMMAND:houselocker(playerid, params[])
{// houselocker [take / put ] [sguns/sdrugs] [amount]
new tmp[ 64 ], tmp2[ 64 ], tmp3;
if(PlayerTemp[playerid][tmphouse]!=-1)
{
new filename[20]; format(filename,sizeof(filename),"Casa%d.txt",House[PlayerTemp[playerid][tmphouse]][HouseID]);
new cursguns = dini_Int(filename,"sguns");
new cursdrugs = dini_Int(filename,"sdrugs");
if(sscanf(params, "ssd",tmp,tmp2,tmp3))
{
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: There is currently %d Guns and %d Drugs in the locker.", dini_Int(filename,"sguns"), dini_Int(filename,"sdrugs"));
return SCP(playerid, "[ take / put ] [ sguns / sdrugs ] [ amount ]");
}
if(!strcmp(tmp, "take"))
{
if(!strlen(tmp2)) return SCP(playerid,"take [ sguns / sdrugs ] [ amount ]");
if(!strcmp(tmp2,"sguns"))
{
if(tmp3>cursguns)
{
SendClientError(playerid, "Invalid amount");
return 1;
}
if(!cursguns)
format(filename,sizeof(filename),"Casa%d.txt",House[PlayerTemp[playerid][tmphouse]][HouseID]);
dini_IntSet(filename, "sguns", cursguns-tmp3);
PlayerInfo[playerid][sguns] += tmp3;
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: You have taken %d guns from your house locker.", tmp3);
}
else if(!strcmp(tmp2,"sdrugs"))
{
if(!cursdrugs)
if(tmp3>cursdrugs)
{
SendClientError(playerid, "Invalid amount");
return 1;
}
dini_IntSet(filename,"sdrugs", cursdrugs-tmp3);
// format(filename,sizeof(filename),"Casa%d.txt",House[PlayerTemp[playerid][tmphouse]][HouseID]);
PlayerInfo[playerid][sdrugs] += tmp3;
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: You have taken %d drugs from your house locker.", tmp3);
}
}
else if(!strcmp(tmp, "put"))
{
if(!strlen(tmp2)) return SCP(playerid,"put [ sguns / sdrugs ] [ amount ]");
if(!strcmp(tmp2,"sguns"))
{
if(PlayerInfo[playerid][sguns]<tmp3)
if(PlayerInfo[playerid][sguns]<0)
{
SendClientError(playerid, "Invalid amount");
return 1;
}
dini_IntSet(filename, "sguns" , cursguns+tmp3);
PlayerInfo[playerid][sguns] -= tmp3;
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: You have put %d guns from your house locker.", tmp3);
}
else if(!strcmp(tmp2,"sdrugs"))
{
if(PlayerInfo[playerid][sdrugs]<tmp3)
{
SendClientError(playerid, "Invalid amount");
return 1;
}
dini_IntSet(filename,"sdrugs", cursdrugs+tmp3);
PlayerInfo[playerid][sdrugs] -= tmp3;
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: You have put %d drugs from your house locker.", tmp3);
}
}
}
return 1;
}
Re: Help -
SpikeSpigel - 05.08.2015
Код:
COMMAND:houselocker(playerid, params[])
{
// houselocker [take / put ] [sguns/sdrugs] [amount]
new tmp[ 64 ], tmp2[ 64 ], tmp3;
if(PlayerTemp[playerid][tmphouse]!=-1)
{
new filename[20]; format(filename,sizeof(filename),"Casa%d.txt",House[PlayerTemp[playerid][tmphouse]][HouseID]);
new cursguns = dini_Int(filename,"sguns");
new cursdrugs = dini_Int(filename,"sdrugs");
if(sscanf(params, "ssd",tmp,tmp2,tmp3))
{
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: There is currently %d Guns and %d Drugs in the locker.", dini_Int(filename,"sguns"), dini_Int(filename,"sdrugs"));
return SCP(playerid, "[ take / put ] [ sguns / sdrugs ] [ amount ]");
}
if(!strcmp(tmp, "take"))
{
if(!strlen(tmp2)) return SCP(playerid,"take [ sguns / sdrugs ] [ amount ]");
if(!strcmp(tmp2,"sguns"))
{
if(tmp3>cursguns)
{
SendClientError(playerid, "Invalid amount");
return 1;
}
if(!cursguns)
format(filename,sizeof(filename),"Casa%d.txt",House[PlayerTemp[playerid][tmphouse]][HouseID]);
dini_IntSet(filename, "sguns", cursguns-tmp3);
PlayerInfo[playerid][sguns] += tmp3;
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: You have taken %d guns from your house locker.", tmp3);
}
else if(!strcmp(tmp2,"sdrugs"))
{
if(!cursdrugs)
if(tmp3>cursdrugs)
{
SendClientError(playerid, "Invalid amount");
return 1;
}
dini_IntSet(filename,"sdrugs", cursdrugs-tmp3);
// format(filename,sizeof(filename),"Casa%d.txt",House[PlayerTemp[playerid][tmphouse]][HouseID]);
PlayerInfo[playerid][sdrugs] += tmp3;
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: You have taken %d drugs from your house locker.", tmp3);
}
}
else if(!strcmp(tmp, "put"))
{
if(!strlen(tmp2)) return SCP(playerid,"put [ sguns / sdrugs ] [ amount ]");
if(!strcmp(tmp2,"sguns"))
{
if(PlayerInfo[playerid][sguns] >= tmp3)
if(PlayerInfo[playerid][sguns] >= 0)
{
SendClientError(playerid, "Invalid amount");
return 1;
}
dini_IntSet(filename, "sguns" , cursguns+tmp3);
PlayerInfo[playerid][sguns] -= tmp3;
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: You have put %d guns from your house locker.", tmp3);
}
else if(!strcmp(tmp2,"sdrugs"))
{
if(PlayerInfo[playerid][sdrugs]<tmp3)
{
SendClientError(playerid, "Invalid amount");
return 1;
}
dini_IntSet(filename,"sdrugs", cursdrugs+tmp3);
PlayerInfo[playerid][sdrugs] -= tmp3;
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: You have put %d drugs from your house locker.", tmp3);
}
}
}
return 1;
}
Your code was a little bit messed up, I have added and removed some brackets and optimized it, just tell me if it gives you any errors or if the pawno crashes when you compile it.
Re: Help -
RedCode - 05.08.2015
What did u do here ?
Re: Help -
SpikeSpigel - 05.08.2015
Just aranged some brackets and functions + tried to repair your problem. Is it working or nah ?
Re: Help -
RedCode - 05.08.2015
I will try
Re: Help -
RedCode - 05.08.2015
U didn't script nothing here , here is like before
Re: Help -
Abagail - 05.08.2015
pawn Код:
if(amount < 0) return // do whatever
Re: Help -
SpikeSpigel - 05.08.2015
Kid, don't get mad. I took me 5-10 minutes just to make the code a reachable one. It had so many brackets and bugs in it. Wait.
Re: Help -
SpikeSpigel - 05.08.2015
He can do amount <= 0 return scm you cant do it. But it will just say, not work.
Код:
COMMAND:houselocker(playerid, params[])
{
// houselocker [take / put ] [sguns/sdrugs] [amount]
new tmp[ 64 ], tmp2[ 64 ], tmp3;
if(PlayerTemp[playerid][tmphouse]!=-1)
{
new filename[20]; format(filename,sizeof(filename),"Casa%d.txt",House[PlayerTemp[playerid][tmphouse]][HouseID]);
new cursguns = dini_Int(filename,"sguns");
new cursdrugs = dini_Int(filename,"sdrugs");
if(sscanf(params, "ssd",tmp,tmp2,tmp3))
{
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: There is currently %d Guns and %d Drugs in the locker.", dini_Int(filename,"sguns"), dini_Int(filename,"sdrugs"));
return SCP(playerid, "[ take / put ] [ sguns / sdrugs ] [ amount ]");
}
if(!strcmp(tmp, "take"))
{
if(!strlen(tmp2)) return SCP(playerid,"take [ sguns / sdrugs ] [ amount ]");
if(!strcmp(tmp2,"sguns"))
{
if(tmp3>cursguns)
{
SendClientError(playerid, "Invalid amount");
return 1;
}
if(!cursguns)
format(filename,sizeof(filename),"Casa%d.txt",House[PlayerTemp[playerid][tmphouse]][HouseID]);
dini_IntSet(filename, "sguns", cursguns-tmp3);
PlayerInfo[playerid][sguns] += tmp3;
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: You have taken %d guns from your house locker.", tmp3);
}
else if(!strcmp(tmp2,"sdrugs"))
{
if(!cursdrugs)
if(tmp3>cursdrugs)
{
SendClientError(playerid, "Invalid amount");
return 1;
}
dini_IntSet(filename,"sdrugs", cursdrugs-tmp3);
// format(filename,sizeof(filename),"Casa%d.txt",House[PlayerTemp[playerid][tmphouse]][HouseID]);
PlayerInfo[playerid][sdrugs] += tmp3;
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: You have taken %d drugs from your house locker.", tmp3);
}
}
else if(!strcmp(tmp, "put"))
{
if(!strlen(tmp2)) return SCP(playerid,"put [ sguns / sdrugs ] [ amount ]");
if(!strcmp(tmp2,"sguns"))
{
if(PlayerInfo[playerid][sguns]<tmp3)
if(PlayerInfo[playerid][sguns]<0)
{
SendClientError(playerid, "Invalid amount");
return 1;
}
dini_IntSet(filename, "sguns" , cursguns+tmp3);
PlayerInfo[playerid][sguns] >= tmp3;
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: You have put %d guns from your house locker.", tmp3);
}
else if(!strcmp(tmp2,"sdrugs"))
{
if(PlayerInfo[playerid][sdrugs]<tmp3)
{
SendClientError(playerid, "Invalid amount");
return 1;
}
dini_IntSet(filename,"sdrugs", cursdrugs+tmp3);
PlayerInfo[playerid][sdrugs] >= tmp3;
SendClientMSG(playerid, COLOR_LIGHTGREY, "LOCKER: You have put %d drugs from your house locker.", tmp3);
}
else
{
if(PlayerInfo[playerid][sdrugs] <=0)
SendClientMSG(playerid, COLOR_LIGHTGREY, "You don't have enough drugs, you bitch.");
return 1;
}
}
}
return 1;
}
Try like this. I resolved the drugs, as I saw it has the same problem. The guns may be resolved but I'm not sure.