[HELP] Random Jobs system -
Scofield62 - 02.02.2012
Hey guys, i need some help to teach me how to use arrays.
I have got this code:
pawn Code:
new Float:weap_job[3][4] =
{
{1390.3326, -1433.2731, 13.5547}, //1st job
{1173.3326, -1308.5277, 13.9932}, //2nd job
{1246.8691, -1258.9777, 13.1773} //3rd job
};
CMD:work(playerid, params[])
{
new pick = random(sizeof(weap_job));
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You are not in any vehicle");
{
SetPlayerCheckpoint(playerid, weap_job[pick][0], weap_job[pick][1], weap_job[pick][2], 7.0);
SendClientMessage(playerid, COLOR_RED, "WORKNAME");
}
return 1;
}
Its work fine but i want to give name for each job (coordinates) cause i want to send a message for a client about name of the job.
For Example
[pawn]
pawn Code:
new Float:weap_job[3][4] =
{
{1390.3326, -1433.2731, 13.5547, "JOBNAME1"}, //1st job
{1173.3326, -1308.5277, 13.9932, "JOBNAME2"}, //2nd job
{1246.8691, -1258.9777, 13.1773, "JOBNAME3"} //3rd job
};
CMD:work(playerid, params[])
{
new pick = random(sizeof(weap_job));
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You are not in any vehicle");
{
SetPlayerCheckpoint(playerid, weap_job[pick][0], weap_job[pick][1], weap_job[pick][2], 7.0);
SendClientMessage(playerid, COLOR_RED, "weap_job[pick][3]");
}
return 1;
}
But in this way doesn't work. Anyone can help me? :$
Re: [HELP] Random Jobs system - T0pAz - 02.02.2012
What is the problem you are having?
Re: [HELP] Random Jobs system -
Scofield62 - 02.02.2012
I want, if i type /work it is pick up a job randomly from the list, and it Send to the client who typed /work the JOB NAME!
For example when i type /work it is picked up this : {1390.3326, -1433.2731, 13.5547, "JOBNAME1"},
And i want to it say to the player in the chat: JOBNAME1
I hope i was understandable.
Re: [HELP] Random Jobs system - T0pAz - 02.02.2012
You are using Float tag on your array and inside the cell, you have a string column. You cannot have string value inside Float datatype.
Re: [HELP] Random Jobs system -
Scofield62 - 02.02.2012
So how can i do it? :S
Re: [HELP] Random Jobs system -
Wesley221 - 02.02.2012
pawn Code:
enum JobsEnum
{
Name[50],
Float:xPos,
Float:yPos,
Float:zPos
}
new Jobs[][JobEnum] =
{
{ "Name", 0.00, 0.00, 0.00 },
};
SetPlayerPos( playerid, Jobs[rand][xPos], Jobs[rand][yPos], Jobs[rand][zPos] );
If you want to use the name of it, just use 'Jobs[rand][Name]'.
Re: [HELP] Random Jobs system -
Scofield62 - 02.02.2012
I'll try it! Thanks!!