Help with command - 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: Help with command (
/showthread.php?tid=430977)
Help with command -
Michael_Cuellar - 16.04.2013
pawn Код:
CMD:giveweed(playerid,params[])
{
if(PlayerInfo[playerid][pJob] == 1)
{
new targetid,type;
if(sscanf(params, "ud", targetid, type)) return SendClientMessage(playerid, -1, "[Usage]: /giveweed [Part of Name/Player ID] [Amount]");
if(type > PlayerInfo[playerid][pWeed])return SendClientMessage(playerid,-1,"ERROR: You do not have that much amount of weeds!");
if(targetid == playerid)return SendClientMessage(playerid,-1,"ERROR: You cannot give drugs to your self!");
PlayerInfo[playerid][pWeed] -= type;
PlayerInfo[targetid][pWeed] +=type;
}
else
{
SendClientMessage(playerid, -1, "you're not a drugdealer.");
}
return 1;
}
How do I make it so it tells the person you are giving it too how much you gave them?
Re : Help with command -
DaTa[X] - 16.04.2013
here you go
pawn Код:
CMD:giveweed(playerid,params[])
{
if(PlayerInfo[playerid][pJob] == 1)
{
new targetid,type,string[128];
new Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name));
if(sscanf(params, "ud", targetid, type)) return SendClientMessage(playerid, -1, "[Usage]: /giveweed [Part of Name/Player ID] [Amount]");
if(type > PlayerInfo[playerid][pWeed])return SendClientMessage(playerid,-1,"ERROR: You do not have that much amount of weeds!");
if(targetid == playerid)return SendClientMessage(playerid,-1,"ERROR: You cannot give drugs to your self!");
PlayerInfo[playerid][pWeed] -= type;
PlayerInfo[targetid][pWeed] +=type;
format(string,sizeof(string),"You have recieved (%d) weeds from %s(%d) ",type,Name,playerid);
SendClientMessage(targetid,-1,string);
}
else
{
SendClientMessage(playerid, -1, "you're not a drugdealer.");
}
return 1;
}
Re: Help with command -
Michael_Cuellar - 16.04.2013
thank you! how would I make it so you have to be within range to use it?
Re: Help with command -
Neil. - 16.04.2013
pawn Код:
CMD:giveweed(playerid,params[])
{
if(IsPlayerInRangeOfPoint(playerid, 10.0, x,y,z)) //Change to your needs
{
if(PlayerInfo[playerid][pJob] == 1)
{
new targetid,type,string[128];
new Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name));
if(sscanf(params, "ud", targetid, type)) return SendClientMessage(playerid, -1, "[Usage]: /giveweed [Part of Name/Player ID] [Amount]");
if(type > PlayerInfo[playerid][pWeed])return SendClientMessage(playerid,-1,"ERROR: You do not have that much amount of weeds!");
if(targetid == playerid)return SendClientMessage(playerid,-1,"ERROR: You cannot give drugs to your self!");
PlayerInfo[playerid][pWeed] -= type;
PlayerInfo[targetid][pWeed] +=type;
format(string,sizeof(string),"You have recieved (%d) weeds from %s(%d) ",type,Name,playerid);
SendClientMessage(targetid,-1,string);
}
else
{
SendClientMessage(playerid, -1, "you're not a drugdealer.");
}
}
else //If the player isn't in the specified range??
return 1;
}