PDA

View Full Version : Cmds


RyanPetersons
22/06/2012, 03:18 PM
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx, tmp[265], tmp2[256];
cmd = strtok(cmdtext, idx);
GetPlayerName(playerid, pname, sizeof(pname));
new string[128];
//register and login stuff
if (strcmp("/createaccount", cmdtext, true, 10) == 0)
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6199 ,-15.5360,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
new pincode; //creating the variable
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) //checks of the player dont forgot any variable
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /createaccount [pincode]");
return 1;
}
pincode = strval(tmp); //'pincode' got saved in an TMP

if (!dini_Exists(udb_encode(pname))) //checks of the player have already made an account
{
dini_Create(udb_encode(pname));
dini_IntSet(udb_encode(pname), "pincode", udb_hash(tmp)); //puts the pincode in the file
dini_IntSet(udb_encode(pname), "bankmoney", 0); // if you want to give the player a starters bonus, then add here an other number
SendClientMessage(playerid, COLOR_GREEN,"You have created new bank account! You can now log in.");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED,"You have already a bank account!"); //if the player have already an bankaccount
}
}
return 1;
}
///////////////////////////
if (strcmp("/loginaccount", cmdtext, true, 10) == 0)
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6213 ,-12.5825,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
new pincode; //creating the variable
tmp = strtok(cmdtext, idx);
if(banklogged[playerid] == 1) //checks if a player is logged in in his account
{
SendClientMessage(playerid, COLOR_RED, "You are already logged in!"); return 1;
}
if(!strlen(tmp)) //checks of the player dont forgot any variable
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /loginaccount [pincode]");
return 1;
}
pincode = strval(tmp); //'pincode' got saved in an TMP
tmp2 = dini_Get(udb_encode(pname), "pincode"); //gets the pincode that is given by creating the account
if (udb_hash(tmp) != strval(tmp2)) //looks of the given pincode match with the pincode in the file
{
SendClientMessage(playerid, COLOR_RED, "You have entered a wrong pincode, try again!"); //if not...
return 1;
}
SendClientMessage(playerid, COLOR_GREEN, "You have logged in into your bankaccount!");//if yes...
banklogged[playerid] = 1;
}
return 1;
}
////////////////////////
//deposit, withdraw and balance cmd's
if(strcmp(cmd, "/deposit", true)==0)
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6089 ,-7.2970,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
new amount; //creating the variable
tmp = strtok(cmdtext, idx);
if(banklogged[playerid] == 0) //checks if a player is logged in in his account
{
SendClientMessage(playerid, COLOR_RED, "You are not logged in on your bank account!"); return 1;
}
if(!strlen(tmp)) // checks of the player dont forgot any variable
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /deposit [amount]"); return 1;
}
amount = strval(tmp); //'amount' got saved in an TMP

new currentm = GetPlayerMoney(playerid);
if(currentm <= amount) //checks if the players current money is lower than the amount he want to deposit
{
SendClientMessage(playerid, COLOR_RED,"You can't deposit more money than you have!"); return 1;
}
if(IsPlayerInRangeOfPoint(playerid, 1.0, 1458.6437,-1011.8918,26.8438))// checks if the player at the bank
{
bankmoney[playerid] += amount; //money goes on the bank account
format(string, sizeof(string), "You have deposited $%d to your bank account.",amount);
SendClientMessage(playerid, COLOR_YELLOW, string);
GivePlayerMoney(playerid, -amount);
}
}
return 1;
}
//////////////////////
if(strcmp(cmd, "/balance", true)==0)
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6208 ,-4.7285,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
if(banklogged[playerid] == 0) //checks if a player is logged in in his account
{
SendClientMessage(playerid, COLOR_RED, "You are not logged in on your bank account!"); return 1;
}
if(IsPlayerInRangeOfPoint(playerid, 1.0, 1458.6437,-1011.8918,26.8438)) //check if the player is at the bank
{
format(string, sizeof(string), "You have currently $%d in your bank account.",bankmoney[playerid]); //show the amount of money on the account
SendClientMessage(playerid, COLOR_YELLOW, string);
}
}
return 1;
}
////////////////////
if(strcmp(cmd, "/withdraw", true)==0)
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6208 ,-9.9430,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
new wamount; //creating the variable
tmp = strtok(cmdtext, idx);
if(banklogged[playerid] == 0) // checks if a player is logged in in his account
{
SendClientMessage(playerid, COLOR_RED, "You are not logged in on your bank account!"); return 1;
}
if(!strlen(tmp)) // checks of the player dont forgot any variable
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /withdraw [amount]"); return 1;
}
wamount = strval(tmp); //'wamount' got saved in an TMP

new bank = bankmoney[playerid];
if(bank <= wamount) // if a player tries to withdraw more money than he haves on his account...
{
SendClientMessage(playerid, COLOR_RED,"You can't withdraw more money than you have!"); return 1;
}
if(IsPlayerInRangeOfPoint(playerid, 1.0, 1458.6437,-1011.8918,26.8438))// check if the player is at the bank
{
bankmoney[playerid] -= wamount; //money is taken from the bank account
format(string, sizeof(string), "You have withdrawed $%d to your bank account.",wamount); // show the amount of withdrawed money
SendClientMessage(playerid, COLOR_YELLOW, string);
GivePlayerMoney(playerid, wamount);// gives the player his money
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED,"You are not at the Bank!"); return 1; //if hes not at the bank
}
}
}
return 0;
}

I want to change these cmds in this form
CMD:withdraw(playerid,params[])

and When I do it in this form, I get some errors, can anyone change the cmds in the form which i given up?

Jarnu
22/06/2012, 03:23 PM
CMD:createaccount(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6199 ,-15.5360,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
new pincode; //creating the variable
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) //checks of the player dont forgot any variable
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /createaccount [pincode]");
return 1;
}
pincode = strval(tmp); //'pincode' got saved in an TMP

if (!dini_Exists(udb_encode(pname))) //checks of the player have already made an account
{
dini_Create(udb_encode(pname));
dini_IntSet(udb_encode(pname), "pincode", udb_hash(tmp)); //puts the pincode in the file
dini_IntSet(udb_encode(pname), "bankmoney", 0); // if you want to give the player a starters bonus, then add here an other number
SendClientMessage(playerid, COLOR_GREEN,"You have created new bank account! You can now log in.");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED,"You have already a bank account!"); //if the player have already an bankaccount
}
}
return 1;
}
///////////////////////////
CMD:loginaccount(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6213 ,-12.5825,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
new pincode; //creating the variable
tmp = strtok(cmdtext, idx);
if(banklogged[playerid] == 1) //checks if a player is logged in in his account
{
SendClientMessage(playerid, COLOR_RED, "You are already logged in!"); return 1;
}
if(!strlen(tmp)) //checks of the player dont forgot any variable
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /loginaccount [pincode]");
return 1;
}
pincode = strval(tmp); //'pincode' got saved in an TMP
tmp2 = dini_Get(udb_encode(pname), "pincode"); //gets the pincode that is given by creating the account
if (udb_hash(tmp) != strval(tmp2)) //looks of the given pincode match with the pincode in the file
{
SendClientMessage(playerid, COLOR_RED, "You have entered a wrong pincode, try again!"); //if not...
return 1;
}
SendClientMessage(playerid, COLOR_GREEN, "You have logged in into your bankaccount!");//if yes...
banklogged[playerid] = 1;
}
return 1;
}
////////////////////////
//deposit, withdraw and balance cmd's
CMD:deposit(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6089 ,-7.2970,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
new amount; //creating the variable
tmp = strtok(cmdtext, idx);
if(banklogged[playerid] == 0) //checks if a player is logged in in his account
{
SendClientMessage(playerid, COLOR_RED, "You are not logged in on your bank account!"); return 1;
}
if(!strlen(tmp)) // checks of the player dont forgot any variable
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /deposit [amount]"); return 1;
}
amount = strval(tmp); //'amount' got saved in an TMP

new currentm = GetPlayerMoney(playerid);
if(currentm <= amount) //checks if the players current money is lower than the amount he want to deposit
{
SendClientMessage(playerid, COLOR_RED,"You can't deposit more money than you have!"); return 1;
}
if(IsPlayerInRangeOfPoint(playerid, 1.0, 1458.6437,-1011.8918,26.8438))// checks if the player at the bank
{
bankmoney[playerid] += amount; //money goes on the bank account
format(string, sizeof(string), "You have deposited $%d to your bank account.",amount);
SendClientMessage(playerid, COLOR_YELLOW, string);
GivePlayerMoney(playerid, -amount);
}
}
return 1;
}
//////////////////////
CMD:balance(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6208 ,-4.7285,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
if(banklogged[playerid] == 0) //checks if a player is logged in in his account
{
SendClientMessage(playerid, COLOR_RED, "You are not logged in on your bank account!"); return 1;
}
if(IsPlayerInRangeOfPoint(playerid, 1.0, 1458.6437,-1011.8918,26.8438)) //check if the player is at the bank
{
format(string, sizeof(string), "You have currently $%d in your bank account.",bankmoney[playerid]); //show the amount of money on the account
SendClientMessage(playerid, COLOR_YELLOW, string);
}
}
return 1;
}
////////////////////
CMD:withdraw(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6208 ,-9.9430,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
new wamount; //creating the variable
tmp = strtok(cmdtext, idx);
if(banklogged[playerid] == 0) // checks if a player is logged in in his account
{
SendClientMessage(playerid, COLOR_RED, "You are not logged in on your bank account!"); return 1;
}
if(!strlen(tmp)) // checks of the player dont forgot any variable
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /withdraw [amount]"); return 1;
}
wamount = strval(tmp); //'wamount' got saved in an TMP

new bank = bankmoney[playerid];
if(bank <= wamount) // if a player tries to withdraw more money than he haves on his account...
{
SendClientMessage(playerid, COLOR_RED,"You can't withdraw more money than you have!"); return 1;
}
if(IsPlayerInRangeOfPoint(playerid, 1.0, 1458.6437,-1011.8918,26.8438))// check if the player is at the bank
{
bankmoney[playerid] -= wamount; //money is taken from the bank account
format(string, sizeof(string), "You have withdrawed $%d to your bank account.",wamount); // show the amount of withdrawed money
SendClientMessage(playerid, COLOR_YELLOW, string);
GivePlayerMoney(playerid, wamount);// gives the player his money
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED,"You are not at the Bank!"); return 1; //if hes not at the bank
}
}
}
return 1;
}

RyanPetersons
22/06/2012, 03:24 PM
Can anyone do it?

RyanPetersons
22/06/2012, 03:26 PM
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(277) : error 017: undefined symbol "tmp"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(277) : error 017: undefined symbol "cmdtext"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(282) : error 017: undefined symbol "tmp"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(287) : error 017: undefined symbol "tmp"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(288) : error 017: undefined symbol "tmp2"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(289) : error 017: undefined symbol "tmp"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(287) : warning 204: symbol is assigned a value that is never used: "pincode"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(304) : warning 217: loose indentation
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(306) : error 017: undefined symbol "tmp"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(306) : error 017: undefined symbol "cmdtext"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(311) : warning 217: loose indentation
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(311) : error 017: undefined symbol "tmp"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(315) : warning 217: loose indentation
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(315) : error 017: undefined symbol "tmp"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(325) : error 017: undefined symbol "string"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(325) : error 017: undefined symbol "string"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(325) : error 029: invalid expression, assumed zero
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(248) : error 017: undefined symbol "tmp"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(248) : error 017: undefined symbol "cmdtext"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(249) : error 017: undefined symbol "tmp"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(254) : error 017: undefined symbol "tmp"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(256) : warning 217: loose indentation
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(259) : warning 217: loose indentation
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(259) : error 017: undefined symbol "tmp"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(248) : error 017: undefined symbol "tmp"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(248) : error 017: undefined symbol "cmdtext"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(249) : error 017: undefined symbol "tmp"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(254) : error 017: undefined symbol "tmp"
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(256) : warning 217: loose indentation
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(259) : warning 217: loose indentation
C:\DOCUME~1\MOSTWA~1\Desktop\lold.pwn(259) : error 017: undefined symbol "tmp"

Jarnu
22/06/2012, 03:31 PM
CMD:createaccount(playerid, params[])
new tmp[265], tmp2[256], idx;
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6199 ,-15.5360,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
new pincode; //creating the variable
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) //checks of the player dont forgot any variable
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /createaccount [pincode]");
return 1;
}
pincode = strval(tmp); //'pincode' got saved in an TMP

if (!dini_Exists(udb_encode(pname))) //checks of the player have already made an account
{
dini_Create(udb_encode(pname));
dini_IntSet(udb_encode(pname), "pincode", udb_hash(tmp)); //puts the pincode in the file
dini_IntSet(udb_encode(pname), "bankmoney", 0); // if you want to give the player a starters bonus, then add here an other number
SendClientMessage(playerid, COLOR_GREEN,"You have created new bank account! You can now log in.");
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED,"You have already a bank account!"); //if the player have already an bankaccount
}
}
return 1;
}
///////////////////////////
CMD:loginaccount(playerid, params[])
new idx, tmp[265], tmp2[256];
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6213 ,-12.5825,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
new pincode; //creating the variable
tmp = strtok(cmdtext, idx);
if(banklogged[playerid] == 1) //checks if a player is logged in in his account
{
SendClientMessage(playerid, COLOR_RED, "You are already logged in!"); return 1;
}
if(!strlen(tmp)) //checks of the player dont forgot any variable
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /loginaccount [pincode]");
return 1;
}
pincode = strval(tmp); //'pincode' got saved in an TMP
tmp2 = dini_Get(udb_encode(pname), "pincode"); //gets the pincode that is given by creating the account
if (udb_hash(tmp) != strval(tmp2)) //looks of the given pincode match with the pincode in the file
{
SendClientMessage(playerid, COLOR_RED, "You have entered a wrong pincode, try again!"); //if not...
return 1;
}
SendClientMessage(playerid, COLOR_GREEN, "You have logged in into your bankaccount!");//if yes...
banklogged[playerid] = 1;
}
return 1;
}
////////////////////////
//deposit, withdraw and balance cmd's
CMD:deposit(playerid, params[])
new idx, tmp[265], tmp2[256];
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6089 ,-7.2970,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
new amount; //creating the variable
tmp = strtok(cmdtext, idx);
if(banklogged[playerid] == 0) //checks if a player is logged in in his account
{
SendClientMessage(playerid, COLOR_RED, "You are not logged in on your bank account!"); return 1;
}
if(!strlen(tmp)) // checks of the player dont forgot any variable
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /deposit [amount]"); return 1;
}
amount = strval(tmp); //'amount' got saved in an TMP

new currentm = GetPlayerMoney(playerid);
if(currentm <= amount) //checks if the players current money is lower than the amount he want to deposit
{
SendClientMessage(playerid, COLOR_RED,"You can't deposit more money than you have!"); return 1;
}
if(IsPlayerInRangeOfPoint(playerid, 1.0, 1458.6437,-1011.8918,26.8438))// checks if the player at the bank
{
bankmoney[playerid] += amount; //money goes on the bank account
format(string, sizeof(string), "You have deposited $%d to your bank account.",amount);
SendClientMessage(playerid, COLOR_YELLOW, string);
GivePlayerMoney(playerid, -amount);
}
}
return 1;
}
//////////////////////
CMD:balance(playerid, params[])
new string[128];
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6208 ,-4.7285,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
if(banklogged[playerid] == 0) //checks if a player is logged in in his account
{
SendClientMessage(playerid, COLOR_RED, "You are not logged in on your bank account!"); return 1;
}
if(IsPlayerInRangeOfPoint(playerid, 1.0, 1458.6437,-1011.8918,26.8438)) //check if the player is at the bank
{
format(string, sizeof(string), "You have currently $%d in your bank account.",bankmoney[playerid]); //show the amount of money on the account
SendClientMessage(playerid, COLOR_YELLOW, string);
}
}
return 1;
}
////////////////////
CMD:withdraw(playerid, params[])
new idx, tmp[265], tmp2[256];
{
if(!IsPlayerInRangeOfPoint(playerid,10.0,2316.6208 ,-9.9430,26.7422)) return SendClientMessage(playerid,0xD6D6D6AA,"You are not in the bank");
{
new wamount; //creating the variable
tmp = strtok(cmdtext, idx);
if(banklogged[playerid] == 0) // checks if a player is logged in in his account
{
SendClientMessage(playerid, COLOR_RED, "You are not logged in on your bank account!"); return 1;
}
if(!strlen(tmp)) // checks of the player dont forgot any variable
{
SendClientMessage(playerid, COLOR_RED, "USAGE: /withdraw [amount]"); return 1;
}
wamount = strval(tmp); //'wamount' got saved in an TMP

new bank = bankmoney[playerid];
if(bank <= wamount) // if a player tries to withdraw more money than he haves on his account...
{
SendClientMessage(playerid, COLOR_RED,"You can't withdraw more money than you have!"); return 1;
}
if(IsPlayerInRangeOfPoint(playerid, 1.0, 1458.6437,-1011.8918,26.8438))// check if the player is at the bank
{
bankmoney[playerid] -= wamount; //money is taken from the bank account
format(string, sizeof(string), "You have withdrawed $%d to your bank account.",wamount); // show the amount of withdrawed money
SendClientMessage(playerid, COLOR_YELLOW, string);
GivePlayerMoney(playerid, wamount);// gives the player his money
return 1;
}
else
{
SendClientMessage(playerid, COLOR_RED,"You are not at the Bank!"); return 1; //if hes not at the bank
}
}
}
return 1;
}

Probably Fixed.