CMD:dm(PID, params[])
{
new string[128], playerName[MAX_PLAYER_NAME];
GetPlayerName(PID, playerName, sizeof(playerName));
if(InDM[PID] == true) // Once again, if they're in a DM arena.
{
return scm(PID, -1, "You're already in a DM arena. (/dmleave)"); // They can't join if they're already in an arena, that wouldn't make sense.
}
else if(sscanf(params,"i",DM[PID])) return scm(PID, -1, "USAGE: /dm <zoneID> (/dmlist)"); // We use sscanf to look for an integer value provided by the user when they type DM as a command.
{
switch (DM[PID]) // We switch through cases in search of the provided integer. As I said, you can add as many as you like. You could get more in depth and check to see if the DM they provide is valid. But this is a simple tutorial.
{
case 0:
{
InDM[PID] = true;
DM[PID] = 0;
SpawnPlayer(PID);
SetPlayerInterior(playerid, 17);
SetPlayerVirtualWorld(PID, 1);
}
}
format(string, sizeof(string), "{77B3D9}[DM Zones] {ffffff}%s(%i) has just entered {77B3D9}DM zone %i {ffffff}(/dm)", playerName, PID, DM[PID]);
scms(-1, string);
}
return 1;
}
|
[15:48:56] [debug] Run time error 4: "Array index out of bounds" [15:48:56] [debug] Attempted to read/write array element at negative index -400 [15:48:56] [debug] AMX backtrace: [15:48:56] [debug] #0 00083ea4 in public OnPlayerModelSelection (playerid=0, response=1, listid=5, modelid=552) at C:\Users\cyber\Desktop\pawn v2.0\lel.pwn:1452 [15:48:56] [debug] #1 native CallLocalFunction () from samp-server.exe [15:48:56] [debug] #2 00072648 in public OnPlayerClickPlayerTextDraw (playerid=0, PlayerText layertextid=32) at H:\gta server cc bukit\pawno\include\mSelection.inc:574 |
CMD:dm(playerid,params[])
{
//some code here... IDK
if(sscanf(params[],"i",DM[playerid]))
{
scm(playerid,-1,"Usage: /dm dm_zone_id"); //Just an example... If typed "/dm string" "/dm" etc
return 1;
}
//rest of the code (if playerid typed "/dm N", N means number)
}
public OnPlayerModelSelection(PID, response, listid, modelid)
{
new VW, INT;
if(listid == Airplanes || listid == Bikes || listid == Boats || listid == Convertible || listid == Helicopters || listid == Industrials || listid == Lowrider || listid == OffRoad || listid == PublicService || listid == RC || listid == Saloon || listid == Sports || listid == StationWagon || listid == Trailer || listid == Unique)
{
if(response)
{
DestroyVehicle(playerCar[PID]);
new Float:pos[4], color[2];
GetPlayerPos(PID, pos[0], pos[1], pos[2]);
GetPlayerFacingAngle(PID, pos[3]);
color[0] = random(256); // the error code
color[1] = random(256);
playerCar[PID] = CreateVehicle(modelid, pos[0], pos[1], pos[2]+2.0, pos[3], color[0], color[1], -1);
VW = GetPlayerVirtualWorld(PID);
INT = GetPlayerInterior(PID);
SetVehicleVirtualWorld(playerCar[PID], VW);
LinkVehicleToInterior(playerCar[PID], INT);
PutPlayerInVehicle(PID, playerCar[PID], 0);
scm(PID, 0xFF0000FF, ""red"[Vehicle] "grey"vehicle Spawned.");
}
else scm(PID, 0xFF0000FF, ""red"[Vehicle] "grey"Canceled selection.");
return 1;
}