Command /v for spawn vehicle
#1

I do this command that one player spawn vehicle with /v [id vehicle] , and i want there are one vehicle * player but don't work very well, cause when one player spawn vehicle and spawn other, the old vehicle go destroy, if i spawn a vehicle and other player spawn vehicle my vehicle go destroy.
[Sorry for the bad english i'm italian and i don't stpeak very well english]

if(strcmp(cmd, "/v", true) == 0)
{
new Float: poscord[3];
new tmp[128];
new color1[128];
new color2[128];
tmp = strtok(cmdtext, idx);
color1 = strtok(cmdtext,idx);
color2 = strtok(cmdtext,idx);
PlayerInfo[playerid][VC] = 2;
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /V [vehicleid] [color1] [color2]");
for(new x=0;x <= PlayerInfo[playerid][VC];x++)
{
if(PlayerInfo[playerid][VC] == 2)
{
DestroyVehicle(x);
}
}
GetPlayerPos(playerid,poscord[0],poscord[1],poscord[2]);
PlayerInfo[playerid][Ve] = CreateVehicle(strval(tmp),poscord[0],poscord[1],poscord[2],0,strval(color1),strval(color2),-1);
PutPlayerInVehicle(playerid,PlayerInfo[playerid][Ve],0);
return 1;
}
Reply
#2

pawn Код:
if(strcmp(cmd, "/v", true) == 0)
{
new Float: poscord[3];
new tmp[128];
new color1[128];
new color2[128];
tmp = strtok(cmdtext, idx);
color1 = strtok(cmdtext,idx);
color2 = strtok(cmdtext,idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /V [vehicleid] [color1] [color2]");
PlayerInfo[playerid][VC] ++;
if (PlayerInfo[playerid][VC] == 2)
{
pInfo[playerid][VC] = 0;
DestroyVehicle(PlayerInfo[playerid][VE]);
}
GetPlayerPos(playerid,poscord[0],poscord[1],poscord[2]);
PlayerInfo[playerid][Ve] =    CreateVehicle(strval(tmp),poscord[0],poscord[1],poscord[2],0,strval(color1),strval(color2),-1);
PutPlayerInVehicle(playerid,PlayerInfo[playerid][Ve],0);
return 1;
}
Reply
#3

i try it don't work
Reply
#4

Why don't you use zcmd instead of default samp command process? Its much more faster and easier to make commands. Anyway this is what i made with zcmd for you.

pawn Код:
CMD:v(playerid, params[])
{
    new
        model,
        Float:x,
        Float:y,
        Float:z,
        Float:rot
    ;

    if(sscanf(params, "i", model)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /v <Vehicle ID>" );
    if(model < 400 || model > 611) return SendClientMessage(playerid, 0xFF0000FF, "Invalid Vehicle ID!");
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, rot);
    if(PlayerInfo[playerid][VC] != -1) DestroyVehicle(PlayerInfo[playerid][VC]);
    PlayerInfo[playerid][VC] = CreateVehicle(model, x, y, z, rot, 0, 0, 200);
    PutPlayerInVehicle(playerid, PlayerInfo[playerid][VC], 0);
    new string[45];
    format(string, sizeof(string), "Vehicle ID: %i has been successfully spawned.", model);
    SendClientMessage(playerid, -1, string);
    return 1;
}
Reply
#5

Quote:
Originally Posted by iOxide
Посмотреть сообщение
Why don't you use zcmd instead of default samp command process? Its much more faster and easier to make commands. Anyway this is what i made with zcmd for you.

pawn Код:
CMD:v(playerid, params[])
{
    new
        model,
        Float:x,
        Float:y
        Float:z
        Float:rot
    ;

    if(sscanf(params, "i", model)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /v <Vehicle ID>" );
    if(model < 400 || model > 611) return SendClientMessage(playerid, 0xFF0000FF, "Invalid Vehicle ID!");
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, rot);
    if(PlayerInfo[playerid][VC] != -1) DestroyVehicle(PlayerInfo[playerid][VC]);
    PlayerInfo[playerid][VC] = CreateVehicle(model, x, y, z, rot, 0, 0, 200);
    PutPlayerInVehicle(playerid, PlayerInfo[playerid][VC], 0);
    new string[45];
    format(string, sizeof(string), "Vehicle ID: %i has been successfully spawned.", model);
    SendClientMessage(playerid, -1, string);
    return 1;
}
pawn Код:
new
        model,
        Float:x,
        Float:y,
        Float:z,
        Float:rot
    ;
You forgot some comas :P
Reply
#6

iOxide thanks i use some code of your command and it work Thanks
[RESOLVED]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)