Help with command
#1

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?
Reply
#2

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;
}
Reply
#3

thank you! how would I make it so you have to be within range to use it?
Reply
#4

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)