/deal cmd with names?
#1

hey guys,

i have made this deal thing so when a player does /deal it gets a random checkpoint somewhere but now i have the problem that when a player types /deal i want it says a message(sendclientmessage) that says whats the name of the player and what he is hauling...
and now the name works but the hauling thing not...
this is my code:
pawn Код:
enum Deals
{
    Name[50],
    Float:xPos,
    Float:yPos,
    Float:zPos
}

new Jobs[][Deals] =
{
    { "Hauling Drugs", 0.00, 0.00, 0.00 },
    { "Hauling Weapons", 0.00, 0.00, 0.00 },
    { "Hauling Whores", 0.00, 0.00, 0.00 },
    { "Hauling Cars", 0.00, 0.00, 0.00 }
};
pawn Код:
new pick = random(sizeof(Jobs));
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED,  "You are not in any vehicle");
    {
        SetPlayerCheckpoint(playerid, Jobs[pick][xPos], Jobs[pick][yPos], Jobs[pick][zPos], 7.0);
        new string[128], Dealname[Deals], pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "Player %s is now Hauling %d",pName, Dealname);
        SendClientMessageToAll(playerid, string);
    }
    return 1;
}
can anyone help me?
(i have the coords to 0.00 but that doesnt matter i want to change later i first want to make the nameof what he is hauling good)

greets niels
Reply
#2

In the Line
pawn Код:
format(string, sizeof(string), "Player %s is now Hauling %d",pName, Dealname);
You created a variable Dealname but what is Dealname?You haven't applied a value to it.
Reply
#3

eeehm yes i did:
pawn Код:
enum Deals
{
    Name[50],
    Float:xPos,
    Float:yPos,
    Float:zPos
}
pawn Код:
new string[128], Dealname[Deals], pName[MAX_PLAYER_NAME];
if this isnt right then pls tell me and help me and say what to change or something?
Reply
#4

(i know this is double post but) CAN ANYONE HELP ME!!!!!!
Reply
#5

Quote:
Originally Posted by -ExG-VirusKiller
Посмотреть сообщение
In the Line
pawn Код:
format(string, sizeof(string), "Player %s is now Hauling %d",pName, Dealname);
You created a variable Dealname but what is Dealname?You haven't applied a value to it.
Quote:
Originally Posted by niels44
Посмотреть сообщение
eeehm yes i did:
No you didnt

An enum is nothing else than a constant list of values
By default it increments by 1 each time
And the name of the enum gets the last value

pawn Код:
enum Deals // 53 - just do "printf("Deals: %d", _: Deals);" to prove it
{
    Name[50], // 0 - 49
    Float:xPos, // 50
    Float:yPos, // 51
    Float:zPos // 52
}
So if you do
pawn Код:
new Dealname[Deals];
Its nothing else do than creating en empty array with 53 cells

To fix your problem you should use Jobs[pick][Name] instead of Dealname
And declare your array as constant if you dont change the content

pawn Код:
stock const Jobs[][Deals] =
{
    { "Hauling Drugs", 0.00, 0.00, 0.00 },
    { "Hauling Weapons", 0.00, 0.00, 0.00 },
    { "Hauling Whores", 0.00, 0.00, 0.00 },
    { "Hauling Cars", 0.00, 0.00, 0.00 }
};
Reply
#6

not working...
i have now this:

pawn Код:
enum Deals
{
    Name[50],
    Float:xPos,
    Float:yPos,
    Float:zPos
}

stock const Jobs[][Deals] =
{
    { "Hauling Drugs", 0.00, 0.00, 0.00 },
    { "Hauling Weapons", 0.00, 0.00, 0.00 },
    { "Hauling Whores", 0.00, 0.00, 0.00 },
    { "Hauling Cars", 0.00, 0.00, 0.00 }
};
pawn Код:
CMD:deal(playerid, params[])
{
    new pick = random(sizeof(Jobs));
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED,  "You are not in any vehicle");
    {
        SetPlayerCheckpoint(playerid, Jobs[pick][xPos], Jobs[pick][yPos], Jobs[pick][zPos], 7.0);
        new string[128], pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "{FF0000}Player %s is now Hauling %d",pName, Jobs[pick][Name]);
        SendClientMessageToAll(playerid, string);
    }
    return 1;
}
pls help
Reply
#7

CAN ANYONE HELP ME?!!
Reply
#8

AH COME ON IS THERE NO ONE WHO CAN HELP ME!?... :\
Reply
#9

Actually there is only one little mistake and its quit obviously if you test the command

But it doesnt seems that you are able to fix it by yourself...
pawn Код:
// same
enum Deals
{
    Name[50],
    Float:xPos,
    Float:yPos,
    Float:zPos
}
pawn Код:
// just removed the "Hauling "
stock const Jobs[][Deals] =
{
    { "Drugs", 0.00, 0.00, 0.00 },
    { "Weapons", 0.00, 0.00, 0.00 },
    { "Whores", 0.00, 0.00, 0.00 },
    { "Cars", 0.00, 0.00, 0.00 }
};
pawn Код:
// changed the last "%d" to "%s" in format because its a string
CMD:deal(playerid, params[])
{
    new pick = random(sizeof(Jobs));
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED,  "You are not in any vehicle");
    {
        SetPlayerCheckpoint(playerid, Jobs[pick][xPos], Jobs[pick][yPos], Jobs[pick][zPos], 7.0);
        new string[128], pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "{FF0000}Player %s is now Hauling %s",pName, Jobs[pick][Name]);
        SendClientMessageToAll(playerid, string); // the first parameter is the color not the playerid, but that doesnt matter if you set a color in the text with "{}"
    }
    return 1;
}
Reply
#10

hey yeah it works thnx man really thnx i just thought that the %d and the %s were the same but i couldnt use it twice in 1 cmd.. but it works now so really thnx man XD i never would figured out that myself XD(btw i dont know that there werent other ppl who saw this but ok)
REP + MAN!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)