ZCMD problem? :-\ - 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: ZCMD problem? :-\ (
/showthread.php?tid=168652)
ZCMD problem? :-\ -
DarkPower - 16.08.2010
The problem is i dont know how to convert command from strcmp / strotk to ZCMD / sscanf
here is command
pawn Код:
if(strcmp(cmd, "/v", true) == 0 || strcmp(cmd, "/vehicle", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new x_nr[512];
x_nr = strtok(cmdtext, idx);
if(!strlen(x_nr))
{
SCM(playerid, COLOR_LIGHTBLUE, "Koristenje: /v [ime]");
SCM(playerid, 0x83BFBFAA, "Moguca imena: parkiraj, lock, unlock, prodaj, lociraj, gpsoff");
return 1;
}
if(strcmp(x_nr,"parkiraj",true) == 0)
{
if(IsPlayerConnected(playerid))
{
new skljuc = GetMojMotor(playerid);
new vehicleid = GetPlayerVehicleID(playerid);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if( PlayerInfo[playerid][pMotoKey] == 999)
{
SCM(playerid, COLOR_LIGHTRED, "Nemas vozilo!");
return 1;
}
if(PlayerInfo[playerid][pMotoKey] != 999)
{
for(new i = 0; i < sizeof(Motori); i++)
{
if(vehicleid == Motori[i][mOsobno])
{
if(skljuc == i)
{
new Float:x,Float:y,Float:z;
new Float:a;
GetVehiclePos(vehicleid, x, y, z);
GetVehicleZAngle(vehicleid, a);
Motori[i][mX] = x;
Motori[i][mY] = y;
Motori[i][mZ] = z;
Motori[i][mA] = a;
DestroyVehicle(vehicleid);
CreateVehicle(Motori[i][mModel],Motori[i][mX],Motori[i][mY],Motori[i][mZ],Motori[i][mA],Motori[i][mpBoja],Motori[i][mdBoja],30000);
PutPlayerInVehicle(playerid, vehicleid, 0);
SCM(playerid, COLOR_GREEN, "parkirano!");
UpdateMotor(i);
return 1;
}
else
{
SCM(playerid, COLOR_LIGHTRED,"Niste na svom vozilu!");
return 1;
}
}
}
}
else
{
SCM(playerid, COLOR_LIGHTRED, "Nemate vozilo!");
}
}
else
{
SCM(playerid, COLOR_LIGHTRED, "Morate biti u svom vozilu da bi ga parkirali!!");
}
}
return 1;
}
else if(strcmp(x_nr,"lock",true) == 0)
{
new skljuc = GetMojMotor(playerid);
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pMotoKey] == 999)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Nemas vozilo!!");
return 1;
}
if(PlayerInfo[playerid][pMotoKey] != 999)
{
format(string, sizeof(string), "Vozilo zakljucano!");
SCM(playerid,COLOR_LIGHTRED,string);
Motori[skljuc][mZakljucan] = 1;
UpdateMotor(skljuc);
return 1;
}
}
return 1;
}
I dont know how to make IN ZCMD when you type /v parkiraj to work but point is i have alot of this shit
pawn Код:
else if(strcmp(x_nr,"unlock",true) == 0)
{
new skljuc = GetMojMotor(playerid);
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pMotoKey] == 999)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Nemas vozilo!!");
return 1;
}
if(PlayerInfo[playerid][pMotoKey] != 999)
{
format(string, sizeof(string), "Vozilo otkljucano!");
SCM(playerid,COLOR_LIGHTGREEN,string);
Motori[skljuc][mZakljucan] = 0;
UpdateMotor(skljuc);
return 1;
}
}
return 1;
}
If you dont understand what i trying to say then ask what you didnt understand
So i just need with ONE ZCMD command ( /v ) to can call this all SUB commands like
[ /v lock ]
[ /v parkiraj ] etc etc
Re: ZCMD problem? :-\ -
DarkPower - 17.08.2010
bump please anyone?
Re: ZCMD problem? :-\ -
iggy1 - 17.08.2010
Im not %100 sure i know what u mean but i think i do. Im not very good at writting tutorials but this should work try and see whats going on its easier than strtok. I commented best i could.
pawn Код:
COMMAND:vehicle(playerid,params[])
{
new sub[24];//this will hold what the player typed in after /vehicle
if(sscanf(params,"s[24]",sub))return SendClientMessage(playerid,0xff0000FF,"Error usage /vehicle [commandid]");//if player didn't type anything after /vehicle send error message
//after sscanf sub will hold what player typed in after /vehicle
if(!strcmp(sub,"lock",true,4))//sub holds params (what player typed in) compare it to 'lock'
{
for(new i; i <= MAX_PLAYERS;i++)
{
if(i == playerid || i == INVALID_PLAYER_ID)continue;
//SetVehicleParamsForPlayer(Motori[i][mModel],i,1,1);
}
SendClientMessage(playerid,0xff0000FF,"Your vehicle is locked");
return 1;
}
if(!strcmp(sub,"unlock",true,6))//compare sub to 'unlock'
{
for(new i; i <= MAX_PLAYERS;i++)
{
if(i == playerid || i == INVALID_PLAYER_ID)continue;
//SetVehicleParamsForPlayer(Motori[i][mModel],i,1,0);
}
SendClientMessage(playerid,0xff0000FF,"Your vehicle is unlocked");
return 1;
}
if(!strcmp(sub,"parkiraj",true,8))
{
//blahblah
}
return 1;
}
COMMAND:v(playerid,params[])
{
return cmd_vehicle(playerid,params);//if player typed /v return the vehicle command.
}
EDIT: setvehicle params function commented so i could test it for errors (no errors).