[HELP ME]Please help wit script
#1

I have script of gundealer!
When you choose this skill, you can sell weapons to yourself, but i need to prevent this!
Please help me, and write your code.
The pwn code here:
Код:
#include <a_samp>
#include <Dini>
#include <dutils>

#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_GREEN 0xDC143C
#define COLOR_RED1 0xFF0000AA

#define TEAM_GUNDEALER 2

#pragma unused ret_memcpy

static gTeam[MAX_PLAYERS]; 


forward Float:GetDistanceBetweenPlayers(p1,p2);

public OnPlayerCommandText(playerid, cmdtext[])
{
  			new tmp[256];
				new string[256];
				new sendername[MAX_PLAYER_NAME];
				new giveplayer[MAX_PLAYER_NAME];
				new cmd[256];
 				new idx;
  			new giveplayerid;
				cmd = strtok(cmdtext, idx);

				if(strcmp(cmd, "/gundealer", true) == 0) {
	gTeam[playerid] = TEAM_GUNDEALER;
  	SendClientMessage(playerid, COLOR_YELLOW, "Ты теперь продавец оружия!");
  SendClientMessage(playerid, COLOR_YELLOW, "Команды: /sellmolotov [id], /sellak47 [id], /sellmp [id]");
	return 1;
	}

				if(strcmp(cmd, "/sellmolotov", true) == 0) {

        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) {
            		SendClientMessage(playerid, COLOR_YELLOW, "Использование: /sellmolotov [ID игрока]");
								return 1;
        }
				giveplayerid = strval(tmp);

  			if (IsPlayerConnected(giveplayerid)) {
    if (gTeam[playerid] == TEAM_GUNDEALER) {
  GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
  GetPlayerName(playerid, sendername, sizeof(sendername));
  GivePlayerWeapon(giveplayerid, 18, 1000);
  GivePlayerMoney(playerid, 2000);
  GivePlayerMoney(giveplayerid, -2000);
  format(string, sizeof(string), "Ты продал 5 молотовых", sendername, playerid);
  SendClientMessage(giveplayerid, COLOR_YELLOW, string);
  format(string, sizeof(string), "%s дал тебе 5 молотовых", giveplayer, giveplayerid, sendername, playerid);
  return 1;
      }else{
        				SendClientMessage(playerid, COLOR_RED1, "Ты не продавец оружия.");
}
            }else{
    format(string, sizeof(string), "id %d Неактивный игрок.", giveplayerid);
		SendClientMessage(playerid, COLOR_YELLOW, string);
}
				return 1;
}


				if(strcmp(cmd, "/sellak47", true) == 0) {

        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) {
            		SendClientMessage(playerid, COLOR_YELLOW, "Использование: /sellak47 [ID игрока]");
								return 1;
        }
				giveplayerid = strval(tmp);

  			if (IsPlayerConnected(giveplayerid)) {
    if (gTeam[playerid] == TEAM_GUNDEALER) {
  GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
  GetPlayerName(playerid, sendername, sizeof(sendername));
  GivePlayerWeapon(giveplayerid, 30, 5000);
  GivePlayerMoney(playerid, 3000);
  GivePlayerMoney(giveplayerid, -3000);
  format(string, sizeof(string), "Ты продал Ak47", sendername, playerid);
  SendClientMessage(giveplayerid, COLOR_YELLOW, string);
  format(string, sizeof(string), "%s Дал тебе Ak47", giveplayer, giveplayerid, sendername, playerid);
  return 1;
      }else{
        				SendClientMessage(playerid, COLOR_RED1, "Ты не продавец оружия.");
}
            }else{
    format(string, sizeof(string), "id %d неактивный игрок.", giveplayerid);
		SendClientMessage(playerid, COLOR_YELLOW, string);
}
				return 1;
}


				if(strcmp(cmd, "/sellmp", true) == 0) {

        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) {
            		SendClientMessage(playerid, COLOR_YELLOW, "использование: /sellmp [ID игрока]");
								return 1;
        }
				giveplayerid = strval(tmp);

  			if (IsPlayerConnected(giveplayerid)) {
    if (gTeam[playerid] == TEAM_GUNDEALER) {
  GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
  GetPlayerName(playerid, sendername, sizeof(sendername));
  GivePlayerWeapon(giveplayerid, 29, 5000);
  GivePlayerMoney(playerid, 1000);
  GivePlayerMoney(giveplayerid, -1000);
  format(string, sizeof(string), "Ты продал мп", sendername, playerid);
  SendClientMessage(giveplayerid, COLOR_YELLOW, string);
  format(string, sizeof(string), "%s дал тебе мп", giveplayer, giveplayerid, sendername, playerid);
  return 1;
      }else{
        				SendClientMessage(playerid, COLOR_RED1, "Ты не продавец оружия.");
}
            }else{
    format(string, sizeof(string), "id %d неактивный игрок.", giveplayerid);
		SendClientMessage(playerid, COLOR_YELLOW, string);
}
				return 1;
}

        return 0;
}
public Float:GetDistanceBetweenPlayers(p1,p2){
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2)){
return -1.00;
}
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,x2,y2,z2);
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));

}
Reply
#2

You have to put:

check if giveplayer is equal to the playerid


pawn Код:
if(giveplayer == playerid)
{
SendClientMessage(playerid,COLOR,"[ERROR] You can't sell guns to yourself.
}
Reply
#3

Ok, i'm try this!
Thanks a lot!
Reply
#4

Quote:
Originally Posted by KnooL
You have to put:

check if giveplayer is equal to the playerid


pawn Код:
if(giveplayer == playerid)
{
SendClientMessage(playerid,COLOR,"[ERROR] You can't sell guns to yourself.
}
giveplayer is an array and playerid is a normal variable, so you can't do that. You can check the giveplayerid and playerid.
Reply
#5

Quote:
Originally Posted by KnooL
You have to put:

check if giveplayer is equal to the playerid


pawn Код:
if(giveplayer == playerid)
{
SendClientMessage(playerid,COLOR,"[ERROR] You can't sell guns to yourself.
}
Код:
filterscripts\gundealer.pwn(31) : error 033: array must be indexed (variable "giveplayer")
Reply
#6

Quote:
Originally Posted by Nexotronix
Код:
filterscripts\gundealer.pwn(31) : error 033: array must be indexed (variable "giveplayer")
I already told you:
Quote:
Originally Posted by Don Correlli
giveplayer is an array and playerid is a normal variable, so you can't do that. You can check the giveplayerid and playerid.
Reply
#7

how to do this? show it in my code? i'm just a beginner!
Reply
#8

pawn Код:
if(giveplayerid == playerid) return SendClientMessage(playerid, COLOR, "[ERROR] You can't sell guns to yourself.");
Reply
#9

Quote:
Originally Posted by Don Correlli
pawn Код:
if(giveplayerid == playerid) return SendClientMessage(playerid, COLOR, "[ERROR] You can't sell guns to yourself.");
where to?


sorry for this all questions
Reply
#10

Quote:
Originally Posted by Nexotronix
Quote:
Originally Posted by Don Correlli
pawn Код:
if(giveplayerid == playerid) return SendClientMessage(playerid, COLOR, "[ERROR] You can't sell guns to yourself.");
where to?


sorry for this all questions
i'm understand where to! Thanks for all!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)