SA-MP Forums Archive
How would I go about doing this? - 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: How would I go about doing this? (/showthread.php?tid=311947)



How would I go about doing this? - 2KY - 19.01.2012

I'm thinking of a vehicle system designated by IDs, meaning the position of your boat is determined by your ID.

At the moment I have:

pawn Код:
new
    g_BoatID = 0,
        p_BoatID[MAX_PLAYERS char] = -1
;
OnPlayerConnect I have:

pawn Код:
g_BoatID++;
Now, my question is, can I place the coordinates in an array, and load them like:

pawn Код:
p_BoatID{playerid} = CreateVehicle(572, BoatPos[g_BoatIDX][playerid], BoatPos[BoatIDY][playerid], BoatPos[BoatIDZ][playerid], BoatPos[BoatA][playerid] ..);



Re: How would I go about doing this? - Lorenc_ - 19.01.2012

Meh, before to skip to anything. Your code wont work if you have more then "0xFF(255)" cars, don't use a CHAR array to cure this.


Re: How would I go about doing this? - 2KY - 19.01.2012

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Meh, before to skip to anything. Your code wont work if you have more then "0xFF(255)" cars, don't use a CHAR array to cure this.
Well, It was planned to be more of a smaller type gamemode, that's the reason I used char; although I appreciate your concern. Could you assist me further?


Re: How would I go about doing this? - Lorenc_ - 19.01.2012

yes, i can.

pawn Код:
static const
    Float: g_BoatSpawns[ ] [ 4 ] =
    {
        { 1.0, 1.0, 1.0, 360.0 }, // Keep making rows till you reach your servers slots.
        { 1.0, 1.0, 1.0, 360.0 }
    }
;
To answer to:
Quote:

Now, my question is, can I place the coordinates in an array, and load them like:




Re: How would I go about doing this? - 2KY - 19.01.2012

Okay, so as to your answer (which I appreciate by the way)..

How would I use that?

pawn Код:
CreateVehicle(572, g_BoatSpawns[0][playerid], g_BoatSpawns[1][playerid], g_BoatSpawns[2][playerid], g_BoatSpawns[3][playerid], 0, 0);
with 0 being x, 1 being y, 2 being z, and 3 being the angle?

Perhaps I should explain, the playerid statement I wanted to be another way to get the row. Meaning if my ID was 0, it would get row 0, et cetera.. Hopefully the code I posted above explained itself though, cause I'm a man of few words..


Re: How would I go about doing this? - 2KY - 19.01.2012

Quote:
Originally Posted by 2KY
Посмотреть сообщение
Okay, so as to your answer (which I appreciate by the way)..

How would I use that?

pawn Код:
CreateVehicle(572, g_BoatSpawns[0][playerid], g_BoatSpawns[1][playerid], g_BoatSpawns[2][playerid], g_BoatSpawns[3][playerid], 0, 0);
with 0 being x, 1 being y, 2 being z, and 3 being the angle?

Perhaps I should explain, the playerid statement I wanted to be another way to get the row. Meaning if my ID was 0, it would get row 0, et cetera.. Hopefully the code I posted above explained itself though, cause I'm a man of few words..
Bump. I really need an answer to this as soon as possible.


Re: How would I go about doing this? - Scenario - 19.01.2012

Something like this could do:

pawn Код:
for(new i = 0; i < sizeof(g_BoatSpawns); i++)
{
    CreateVehicle(572, g_BoatSpawns[0][playerid], g_BoatSpawns[1][playerid], g_BoatSpawns[2][playerid], g_BoatSpawns[3][playerid], 0, 0);
}



Re: How would I go about doing this? - 2KY - 19.01.2012

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Something like this could do:

pawn Код:
for(new i = 0; i < sizeof(g_BoatSpawns); i++)
{
    CreateVehicle(572, g_BoatSpawns[0][playerid], g_BoatSpawns[1][playerid], g_BoatSpawns[2][playerid], g_BoatSpawns[3][playerid], 0, 0);
}
Thank you!