Help About Virtual World.
#1

Hello I made Command to Spectate Player in Event. But What that code of pawno that If the Player isn't in Virtual World And I try to spec him then He should say to me like that:

"This Player isn't in Event"

And Also I want to make that Command like /virtuallist to see the List of those Players who are in Event.

Apologize for Bad English !

Thanks for Help in Advance.
Reply
#2

LOL, I mean that If Player in Real World and I am in Virtual World so I can't spec that Player Who isn't in Virtual World. I made a Command that is telling me "You can't use Admins Commands in Real World". I made new Command for Event makers like /espec. But my Question is, I can spec those Players who are in Real World by using /espec Command which is Event Command, not Real World Command. I want that I can't spec those who are in Real World.
Reply
#3

Quote:
Originally Posted by MAFIAWARS
Посмотреть сообщение
LOL, I mean that If Player in Real World and I am in Virtual World so I can't spec that Player Who isn't in Virtual World. I made a Command that is telling me "You can't use Admins Commands in Real World". I made new Command for Event makers like /espec. But my Question is, I can spec those Players who are in Real World by using /espec Command which is Event Command, not Real World Command. I want that I can't spec those who are in Real World.
"isnt in virtual world" Then obviously it is *See below*.
Код:
if (GetPlayerVirtualWorld(playerid) >= 0) {
  //In event
}
Reply
#4

Thank you !

I have one more Question, How to Destroy All Vehicles with one Command?
Reply
#5

pawn Код:
CMD:destroyvehicles( playerid, params[ ] )
{
    if( !IsPlayerAdmin( playerid ) ) return 1;
    for( new v = 1; v < MAX_VEHICLES; v++ ) DestroyVehicle( v );
    return 1;
}
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
CMD:destroyvehicles( playerid, params[ ] )
{
    if( !IsPlayerAdmin( playerid ) ) return 1;
    for( new v = 1; v < MAX_VEHICLES; v++ ) DestroyVehicle( v );
    return 1;
}
pawn Код:
for( new v = 1; v <= MAX_VEHICLES; v++ ) DestroyVehicle( v );
Otherwise you will miss id 2000
Reply
#7

Quote:
Originally Posted by Grimrandomer
Посмотреть сообщение
pawn Код:
for( new v = 1; v <= MAX_VEHICLES; v++ ) DestroyVehicle( v );
Otherwise you will miss id 2000
If you do not want to crash your server, then don't do that!

MAX_VEHICLES is defined as 2000 which means 0-1999. However, the vehicleid starts from 1.

If you have an array, let's say:
pawn Код:
new
    Check_Something[ MAX_VEHICLES ]
;

// somewhere
for( new v = 1; v <= MAX_VEHICLES; v++ ) Check_Something[ v ] = 0;
When 2000 gets passed in the index, it will cause index out of bounds because it expected the max value to be 1999.
Reply
#8

WRONG, there are 2000 vehicles.


SA-MP allows 2000 vehicles, starting at vehicle id 1, up to and including vehicle id 2000, so accessing an array of size MAX_VEHICLES with vehicle id 2000 will crash, so you need an array of size 2001 (MAX_VEHICLES+1) if you want to access an array with its vin.

pawn Код:
new vehicles[MAX_VEHICLES+1];

vehicles[vin];
Or you can access the array with "VIN - 1" and have access to vin 2000.

pawn Код:
new vehicles[MAX_VEHICLES];

vehicles[vin -1];
Which ever is easier.
Reply
#9

I've to admit that I totally forgot about MAX_VEHICLES+1 and it indeed works; however, your second method will not work since it goes v -1 (v = 1) so it's 0. 0 is not a valid vehicleid.
Reply
#10

no, you dont understand me,

Say an array is MAX_VEHICLES indexes 0 to 1999
Vehicle ids are 1 to 2000, so if you access the array with "vehicleid -1" you get 0 to 1999
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)