24.08.2010, 09:55
(
Последний раз редактировалось iggy1; 24.08.2010 в 12:14.
)
Hi last night i released a script for testing what objects would look good when they are on a player. Its very basic so i wanted to just add a couple more commands. So i wanted to make a command that offsets the object from the bone to which the object is attached. Here is the problem code,
Note: Iv tryed making the distance variable a float but i get tag missmatch on the "SetPlayerHoldingObject" lines.
Also the "if(distance < 1 || distance > 100)" line is failing if i type, lets say 500.
Any help very much appreciated will add anyone who helps to credits ect.
EDIT: FIXED!!!!!!
pawn Код:
COMMAND:offsethandobject(playerid,params[])
{
new id,axis[2],distance;
if(sscanf(params,"ds[2]d",id,axis,distance))return SendClientMessage(playerid,0xff0000FF,"ERROR: usage /offsethandobject [id][x/y/z][distance] (example /offsethandobject 1 -x 50)");
if(!strcmp(axis,"-x",true))
{
if(distance < 1 || distance > 100)return SendClientMessage(playerid,0xff0000FF,"Invalid distance range is 1 to 100");
{
new mx = mx - distance;
SetPlayerHoldingObject(id,holdingobjects[id],-mx,0,0);
SendClientMessage(playerid,0xff0000FF,"ERROR:");//this here just to test to see if it executes (it doesn't)
return 1;
}
}
if(!strcmp(axis,"+x",true))
{
if(distance < 1 || distance > 100)return SendClientMessage(playerid,0xff0000FF,"Invalid distance range is 1 to 100");
{
new mx = mx + distance;
SetPlayerHoldingObject(id,holdingobjects[id],mx,0,0);
SendClientMessage(playerid,0xff0000FF,"ERROR:");
return 1;
}
}
return 1;
}
Also the "if(distance < 1 || distance > 100)" line is failing if i type, lets say 500.
Any help very much appreciated will add anyone who helps to credits ect.
EDIT: FIXED!!!!!!
pawn Код:
COMMAND:offsethandobject(playerid,params[])
{
new oid,bidstr[20],axis[5],Float:distance;
if(sscanf(params,"ds[20]s[5]f",oid,bidstr,axis,distance))return SendClientMessage(playerid,0xff0000FF,"ERROR: usage /createhandobject [objectid][boneid][axis)[distance]");
if(distance < 0.1 || distance > 100)return SendClientMessage(playerid,0xff0000FF,"Invalid distance range is 0.1 to 100.0");
if(!strcmp(axis,"-x",true))
{
SetPlayerHoldingObject(playerid,oid,GetBoneID(bidstr),-distance);
return 1;
}
if(!strcmp(axis,"+x",true))
{
SetPlayerHoldingObject(playerid,oid,GetBoneID(bidstr),distance);
return 1;
}
if(!strcmp(axis,"-y",true))
{
SetPlayerHoldingObject(playerid,oid,GetBoneID(bidstr),0.0,-distance);
return 1;
}
if(!strcmp(axis,"+y",true))
{
SetPlayerHoldingObject(playerid,oid,GetBoneID(bidstr),0.0,distance);
return 1;
}
if(!strcmp(axis,"-z",true))
{
SetPlayerHoldingObject(playerid,oid,GetBoneID(bidstr),0.0,0.0,-distance);
return 1;
}
if(!strcmp(axis,"+z",true))
{
SetPlayerHoldingObject(playerid,oid,GetBoneID(bidstr),0.0,0.0,distance );
}
else SendClientMessage(playerid,0xff0000FF,"ERROR: Invalid axis use [-x/+x/-y/+y-z/+z] pick one!");
return 1;
}
GetBoneID(bonename[])
{
if(!strcmp(bonename,"spine",true)) return 1;
if(!strcmp(bonename,"head",true)) return 2;
if(!strcmp(bonename,"leftupperarm",true)) return 3;
if(!strcmp(bonename,"rightupperarm",true)) return 4;
if(!strcmp(bonename,"lefthand",true)) return 5;
if(!strcmp(bonename,"righthand",true)) return 6;
if(!strcmp(bonename,"leftthigh",true)) return 7;
if(!strcmp(bonename,"rightthigh",true)) return 8;
if(!strcmp(bonename,"leftfoot",true)) return 9;
if(!strcmp(bonename,"rightfoot",true)) return 10;
if(!strcmp(bonename,"rightcalf",true)) return 11;
if(!strcmp(bonename,"leftcalf",true)) return 12;
if(!strcmp(bonename,"leftforearm",true)) return 13;
if(!strcmp(bonename,"rightforearm",true)) return 14;
if(!strcmp(bonename,"leftclavical",true)) return 15;
if(!strcmp(bonename,"rightclavical",true)) return 16;
if(!strcmp(bonename,"neck",true)) return 17;
if(!strcmp(bonename,"jaw",true)) return 18;
else return 2;
}