SA-MP Forums Archive
needing help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: needing help (/showthread.php?tid=199744)



needing help - _Sprite_ - 16.12.2010

How can i make a /v cmd to spawn vehicles?


Re: needing help - Ash. - 16.12.2010

Something like this: - I havent tested this, but it should work.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
     if(!strcmp("/v", cmdtext))
     {
          strdel(cmdtext, 0, 3);
          if(strlen(cmdtext) == 0) return SendClientMessage(playerid, COLOUR, "Usage: /v [vid]");
          new Float:x, Float:y, Float:z;
          GetPlayerPos(playerid, x, y, z);
          CreateVehicle(strval(cmdtext), x+3, y+3, z, 0.0, -1, -1, -1);
          return 1;
     }
     return 0;
}



Re: needing help - _Sprite_ - 16.12.2010

i get this

EDIT: thanks it works man!

but when i do /v 493 it says unknown cmd


Re: needing help - blackwave - 16.12.2010

Quote:
Originally Posted by _Sprite_
Посмотреть сообщение
i get this

EDIT: thanks it works man!

but when i do /v 493 it says unknown cmd
Use sscanf or dcmd... Strcmp is pretty hard.


Re: needing help - veyron - 16.12.2010

ZCMD
pawn Код:
COMMAND:v(playerid, params[])
{
    new tmp;
    if(sscanf(params,"i",tmp)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /adcar [CarID]");
    else
    {
        new Float:x,Float:y,Float:z,Float:Angle;
        GetPlayerPos(playerid,x,y,z);
        GetPlayerFacingAngle(playerid,Angle);
        CreateVehicle(tmp,x+2*floatsin(-Angle, degrees),y+2*floatcos(-Angle, degrees),z+1,Angle+90,0,0,99999999999);
        return 1;
    }
}
strtok
pawn Код:
if(strcmp(cmd, "/v", true) == 0)
{
    new tmp[256];
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /v [carid]");
    new modelid= strval(tmp);
    new Float:x,Float:y,Float:z,Float:Angle;
    GetPlayerPos(playerid,x,y,z);
    GetPlayerFacingAngle(playerid,Angle);
    CreateVehicle(modelid,x+3*floatsin(-Angle, degrees),y+3*floatcos(-Angle, degrees),z+1,Angle+90,0,0,99999999999);
    return 1;
}