/adv command 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)
+--- Thread: /adv command help! (
/showthread.php?tid=287864)
/adv command help! -
Panormitis - 05.10.2011
Hello guys, i want to make a command that when someone is in RangeOfPoint that i will set, when he type /adv [message] ,a message <<[ADVERT] themessagehere>> will apear to all players and 70$ will removed from the player, How to do this?? :/
Re: /adv command help! -
Pharrel - 05.10.2011
pawn Код:
CMD:adv(playerid, params[])
{
if(!strlen(params[0])) return SendClientMessage(playerid, -1, "Use /adv [message");
if(IsPlayerInRangeOfPoint(playerid, RANGE, posX, posY, posZ))
{
SendClientMessageToAll(-1, params[0]);
GivePlayerMoney(playerid, -70);
return 1;
}
else return SendClientMessage(playerid, -1, "You arent in the spot to use this command!");
}
Re: /adv command help! -
Panormitis - 05.10.2011
Quote:
Originally Posted by Pharrel
pawn Код:
CMD:adv(playerid, params[]) { if(!strlen(params[0])) return SendClientMessage(playerid, -1, "Use /adv [message"); if(IsPlayerInRangeOfPoint(playerid, RANGE, posX, posY, posZ)) { SendClientMessageToAll(-1, params[0]); GivePlayerMoney(playerid, -70); return 1; } else return SendClientMessage(playerid, -1, "You arent in the spot to use this command!"); }
|
Can you Please give it ine default code? :/
Re: /adv command help! -
aRoach - 05.10.2011
pawn Код:
CMD:adv(playerid, params[])
{
if(!strlen(params[0])) return SendClientMessage(playerid, -1, "Use /adv [message");
if(!IsPlayerInRangeOfPoint(playerid, RANGE, posX, posY, posZ)) return SendClientMessage(playerid, -1, "You arent in the spot to use this command!");
if(GetPlayerMoney(playerid) < 70) return SendClientMessage(playerid, -1, "You don't have enough money !");
SendClientMessageToAll(-1, params[0]);
GivePlayerMoney(playerid, -70);
return 1;
}
You want with STRCMP ?
Re: /adv command help! -
Panormitis - 05.10.2011
Quote:
Originally Posted by aRoach
pawn Код:
CMD:adv(playerid, params[]) { if(!strlen(params[0])) return SendClientMessage(playerid, -1, "Use /adv [message"); if(!IsPlayerInRangeOfPoint(playerid, RANGE, posX, posY, posZ)) return SendClientMessage(playerid, -1, "You arent in the spot to use this command!"); if(GetPlayerMoney(playerid) < 70) return SendClientMessage(playerid, -1, "You don't have enough money !");
SendClientMessageToAll(-1, params[0]); GivePlayerMoney(playerid, -70); return 1; }
You want with STRCMP ?
|
Yes please!
Re: /adv command help! -
Panormitis - 05.10.2011
Quote:
Originally Posted by Panormitis
Yes please!
|
Please Any help? :/
Re: /adv command help! -
aRoach - 05.10.2011
Add this at OnPlayerCommandText:
pawn Код:
new tmp[ 128 ], cmd[128], idx;
cmd = strtok( cmdtext, idx );
The Command:
pawn Код:
if( !strcmp( cmd, "/adv" ) )
{
new str[ 256 char ];
tmp = strtok( cmdtext, idx );
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "Use /adv [message");
if(!IsPlayerInRangeOfPoint(playerid, RANGE, posX, posY, posZ)) return SendClientMessage(playerid, -1, "You arent in the spot to use this command!");
if(GetPlayerMoney(playerid) < 70) return SendClientMessage(playerid, -1, "You don't have enough money !");
format( str, sizeof str, "<<[ADVERT] %s>>", tmp );
SendClientMessageToAll(-1, params[0]);
GivePlayerMoney(playerid, -70);
return 1;
}
And this is the Function:
pawn Код:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
Re: /adv command help! -
Jack_Leslie - 05.10.2011
Just use cmd...