/pay help!!! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /pay help!!! (
/showthread.php?tid=206268)
/pay help!!! -
Aekzakis - 03.01.2011
Can someone please give me a code script for /pay!!!!!!
![Confused](images/smilies/confused.png)
![Confused](images/smilies/confused.png)
![Confused](images/smilies/confused.png)
Re: /pay help!!! -
iJumbo - 03.01.2011
what this script have 2 do?
Re: /pay help!!! -
Aekzakis - 03.01.2011
Quote:
Originally Posted by [ISS]jumbo
what this script have 2 do?
|
i want one player give money to the other, when someone type /pay [playerid] [amount] the money will go to the receiver.!! Any code script?
![Confused](images/smilies/confused.png)
![Confused](images/smilies/confused.png)
![Confused](images/smilies/confused.png)
Re: /pay help!!! -
Sascha - 03.01.2011
pawn Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
dcmd_pay(playerid, params[])
{
new idx;
tmp = strtok(params, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, 0x801818AA, "/pay [id] [amount]");
}else{
new pname1[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME], string[150], pid;
pid = strval(tmp);
if(!IsPlayerConnected(pid)){
SendClientMessage(playerid, 0x801818AA, "Invalid player");
return 1;
}
tmp = strrest(params, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, 0x801818AA, "/pay [id] [amount]");
}
new amount = strval(tmp);
if(GetPlayerMoney(playerid) < amount){
SendClientMessage(playerid, 0x801818AA, "You don't have enough money");
}else{
GetPlayerName(playerid, pname1, sizeof(pname1));
GetPlayerName(pid, pname2, sizeof(pname2));
format(string, sizeof(string), "*%s gave %s %d$", pname1, pname2, amount);
SendClientMessageToAll(0x801818AA, string);
GivePlayerMoney(pid, amount);
GivePlayerMoney(playerid, -amount);
}
}
return 1;
}
stock strrest(const string[], index)
{
new length = strlen(string),offset = index,result[256];
while ((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r'))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
haven't tested it thought
Re: /pay help!!! -
Aekzakis - 03.01.2011
Quote:
Originally Posted by Sascha
pawn Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
dcmd_pay(playerid, params[]) { new idx; tmp = strtok(params, idx); if(!strlen(tmp)){ SendClientMessage(playerid, 0x801818AA, "/pay [id] [amount]"); }else{ new pname1[MAX_PLAYER_NAME], pname2[MAX_PLAYER_NAME], string[150], pid; pid = strval(tmp); if(!IsPlayerConnected(pid)){ SendClientMessage(playerid, 0x801818AA, "Invalid player"); return 1; } tmp = strrest(params, idx); if(!strlen(tmp)){ SendClientMessage(playerid, 0x801818AA, "/pay [id] [amount]"); } new amount = strval(tmp); if(GetPlayerMoney(playerid) < amount){ SendClientMessage(playerid, 0x801818AA, "You don't have enough money"); }else{ GetPlayerName(playerid, pname1, sizeof(pname1)); GetPlayerName(pid, pname2, sizeof(pname2)); format(string, sizeof(string), "*%s gave %s %d$", pname1, pname2, amount); SendClientMessageToAll(0x801818AA, string); GivePlayerMoney(pid, amount); GivePlayerMoney(playerid, -amount); } } return 1; } stock strrest(const string[], index) { new length = strlen(string),offset = index,result[256]; while ((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r')) { result[index - offset] = string[index]; index++; } result[index - offset] = EOS; return result; }
haven't tested it thought
|
i got this erros: what i did wrong?
: warning 219: local variable "string" shadows a variable at a preceding level
: warning 203: symbol is never used: "dcmd_pay"
![Huh?](images/smilies/confused.gif)
![Huh?](images/smilies/confused.gif)
?
Re: /pay help!!! -
iJumbo - 03.01.2011
use the command in lvdm gm ...
Re: /pay help!!! -
Aekzakis - 03.01.2011
Quote:
Originally Posted by [ISS]jumbo
use the command in lvdm gm ...
|
I didn't understand what you mean!
![Huh?](images/smilies/confused.gif)
![Huh?](images/smilies/confused.gif)
Re: /pay help!!! -
iJumbo - 03.01.2011
go to gm directory find lvdm.pwn open search for this command is into..
Re: /pay help!!! -
blackwave - 03.01.2011
Also you forgot to add this line:
on the:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
// ADD the line here
}
Re: /pay help!!! -
Aekzakis - 03.01.2011
i get so many errors