SA-MP Forums Archive
cmd - 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: cmd (/showthread.php?tid=640227)



cmd - crukk11 - 30.08.2017

1.my command is bug

PHP код:
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;
} 
the bug is:i have 1 room deathmatch but if i type 2 room,the sendclientmesseage show but no show (you type wrong room name)

2.the crash detect show this
Quote:

[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, PlayerTextlayertextid=32) at H:\gta server cc bukit\pawno\include\mSelection.inc:574




Re: cmd - crukk11 - 30.08.2017

help


Re: cmd - Dayrion - 30.08.2017

What room id do you have?


Re: cmd - crukk11 - 30.08.2017

i have only 1 room.it should say no room when i type room 2


Re: cmd - 10MIN - 30.08.2017

You used sscanf wrong...
It should be like:
PHP код:
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)
} 



Re: cmd - crukk11 - 30.08.2017

what do you mean


Re: cmd - crukk11 - 30.08.2017

anyone


Re: cmd - crukk11 - 31.08.2017

Help


Re: cmd - Kane - 31.08.2017

Are the two problems related?

Show line 1452.


Re: cmd - crukk11 - 31.08.2017

PHP код:
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;
    }