30.04.2010, 07:45
Hello,
I got some weird bugs in my server with the commands. They don't work. I show you the code.
And here are the DCMD commands, if you need them (they don't work to, so the bug must be in OnPlayerCommandText)
I got some weird bugs in my server with the commands. They don't work. I show you the code.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(deposit,7,cmdtext);
dcmd(withdraw,8,cmdtext);
dcmd(bank,4,cmdtext);
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
new string[248];
if (strcmp("/licenses", cmdtext, true, 10) == 0)
{
if(IsPlayerInRangeOfPoint(playerid,5.0,-2031.7733,-116.9298,1035.1719))
{
new dtests[] = "1\tDriving License - 800$\n2\tFlying License - 2000$\n3\tGun License - 500$";
ShowPlayerDialog(playerid,999,DIALOG_STYLE_LIST,"Licenses, Chose One:",dtests,"Test","Exit");
return 1;
}
else if(!IsPlayerInRangeOfPoint(playerid,5.0,-2031.7733,-116.9298,1035.1719))
{
SendClientMessage(playerid,grey,"--> This command is only used at the SanFiero School.");
}
return 1;
}
if (strcmp("/sl", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid,grey," Use: /sl [driving/flying/gun].");
return 1;
}
if (strcmp("/sl driving", cmdtext, true, 10) == 0)
{
if(PlayerInfo[playerid][DrivingLicense] == 0)
{
format(string,sizeof(string)," %s doesnt have a valid Driving License",pName);
SendClientMessageToAll(aquablue,string);
}
else if(PlayerInfo[playerid][DrivingLicense] == 1)
{
format(string,sizeof(string)," %s shows a legit Driving License.",pName);
SendClientMessageToAll(aquablue,string);
}
return 1;
}
if (strcmp("/sl flying", cmdtext, true, 10) == 0)
{
if(PlayerInfo[playerid][FlyingLicense] == 0)
{
format(string,sizeof(string)," %s doesn't have a valid Flying License",pName);
SendClientMessageToAll(aquablue,string);
}
else if(PlayerInfo[playerid][FlyingLicense] == 1)
{
format(string,sizeof(string)," %s shows a legit Flying License.",pName);
SendClientMessageToAll(aquablue,string);
}
}
if (strcmp("/sl gun", cmdtext, true, 10) == 0)
{
if(PlayerInfo[playerid][GunLicense] == 0)
{
format(string,sizeof(string)," %s doesn't have a valid Gun License",pName);
SendClientMessageToAll(aquablue,string);
}
else if(PlayerInfo[playerid][GunLicense] == 1)
{
format(string,sizeof(string)," %s shows a legit Gun License.",pName);
SendClientMessageToAll(aquablue,string);
}
}
return 0;
}
pawn Код:
dcmd_bank(playerid,params[])
{
#pragma unused params
if (IsPlayerInRangeOfPoint(playerid,20.0,1459.22, -1012.63, 28.84) || IsPlayerInRangeOfPoint(playerid,20.0,-1495.398,919.942,7.187))
{
ShowPlayerDialog(playerid,DIALOG_BANK,DIALOG_STYLE_LIST,"--> Withdraw, deposit, or see how much money you have?","Deposit\nWithdraw\nCheck Bank Account","Choose","Cancel");
}
else return SendClientMessage(playerid,red,"--> You must be near the Bank! [The Money Sign]");
return 1;
}
dcmd_deposit(playerid,params[])
{
new amout=strval(params);
if (IsPlayerInRangeOfPoint(playerid,20.0,1459.22, -1012.63, 28.84))
{
if (strlen(params)>0)
{
if (IsNumeric(params))
{
if (GetPlayerMoney(playerid)>=amout)
{
GivePlayerMoney(playerid,-amout);
bnk_UserSetInt(PlayerName(playerid),"in",bnk_UserInt(PlayerName(playerid),"in")+amout);
new string[200];
format(string,sizeof(string),"--> You have succesfully deposited %i$ , Now in bank : %i$ .",amout,bnk_UserInt(PlayerName(playerid),"in"));
SendClientMessage(playerid,red,string);
}
else return SendClientMessage(playerid,red,"--> You don't have enough money!");
}
else return SendClientMessage(playerid,red,"--> Amout must be numeric !");
}
else return SendClientMessage(playerid,red,"--> Syntax Error: /deposit [AMOUT]");
}
else return SendClientMessage(playerid,red,"--> You must be near a bank . ");
return 1;
}
dcmd_withdraw(playerid,params[])
{
new amout=strval(params);
if (IsPlayerInRangeOfPoint(playerid,20.0,1459.22, -1012.63, 28.84))
{
if (strlen(params)>0)
{
if (IsNumeric(params))
{
if (amout<=bnk_UserInt(PlayerName(playerid),"in"))
{
bnk_UserSetInt(PlayerName(playerid),"in",bnk_UserInt(PlayerName(playerid),"in")-amout);
new string[200];
format(string,sizeof(string),"--> You have succesfully withdrawed %i$ , Now in bank : %i$ .",amout,bnk_UserInt(PlayerName(playerid),"in"));
SendClientMessage(playerid,yellow,string);
GivePlayerMoney(playerid,amout);
}
else return SendClientMessage(playerid,red,"--> Not enough money in the bank!");
}
else return SendClientMessage(playerid,red,"--> Amout must be numeric !");
}
else return SendClientMessage(playerid,red,"--> Syntax Error: /withdraw [amount]");
}
else return SendClientMessage(playerid,red,"--> You must be near the bank");
return 1;
}
IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}