31.12.2011, 04:21
((Notice: I am a beginning-scripter, i am not the slightest bit intelligent with array's and such))
Greetings.
I have a question about array's.
So, this is something i'm currently scripting.
This script creates a radio at my position when i type /createradio, and deletes it when i type /deleteradio. Lets say, i had the array as RADIO[32]. ((Just to say, i can't explain very well)).
I want it so when i /createradio, it will spawn the radio at my position, and make it number 0 ((if it was the first time i did it)). Now, i want it so if i type it again, it will add it up once more, so if i did it once previously, it would make the RADIO array = 1, and so forth. Because i don't want to make several "If(IsPlayerInRangeOfPoint)" 's, and i would like to save line space. I also want it so when i type /deleteradio, it will check if i'm near one of the radio's i made, and delete that one only.
Sorry if ^^ that was to much to ask, i'm having trouble and i'm not the slightest bit very intelligent in scripting right now.
Thanks in advance, /KurtBag\
Greetings.
I have a question about array's.
So, this is something i'm currently scripting.
pawn Код:
//Top of the script
new RADIO[2]
//Somewhere down below
CMD:createradio(playerid, params[])
{
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] >= 5)
{
new Float:X, Float:Y, Float:Z, Float:angle;
GetPlayerFacingAngle(playerid, angle);
GetPlayerPos(playerid, X,Y,Z);
RADIO[1] = CreateObject(2102, X, Y, Z, 0, 0, angle, 200);
}
return 1;
}
CMD:deleteradio(playerid, params[])
{
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] >= 5)
{
new Float:X, Float:Y, Float:Z;
GetObjectPos(RADIO[1], X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, 20.0, X, Y, Z))
{
DestroyObject(RADIO[1]);
}
}
return 1;
}
I want it so when i /createradio, it will spawn the radio at my position, and make it number 0 ((if it was the first time i did it)). Now, i want it so if i type it again, it will add it up once more, so if i did it once previously, it would make the RADIO array = 1, and so forth. Because i don't want to make several "If(IsPlayerInRangeOfPoint)" 's, and i would like to save line space. I also want it so when i type /deleteradio, it will check if i'm near one of the radio's i made, and delete that one only.
Sorry if ^^ that was to much to ask, i'm having trouble and i'm not the slightest bit very intelligent in scripting right now.
Thanks in advance, /KurtBag\