Stop players surfing specific objects? -
Phil_Cutcliffe - 22.02.2014
Is there any way to stop players surfing objects whilst they're editing them? If a player is building their house they are able to surf the object they are editing and fly around all over the place. I was going to create a dynamic cube round each of my interiors to prevent this but if I can stop players surfing objects this won't be a problem.
Re: Stop players surfing specific objects? -
Konstantinos - 22.02.2014
I guess you can check if the player is surfing any object while editing them, right?
https://sampwiki.blast.hk/wiki/GetPlayerSurfingObjectID
Re: Stop players surfing specific objects? -
AlonzoTorres - 22.02.2014
https://sampwiki.blast.hk/wiki/GetPlayerSurfingObjectID
Haha, the guy above me was one second quicker.
Re: Stop players surfing specific objects? -
Phil_Cutcliffe - 22.02.2014
Quote:
Originally Posted by Konstantinos
|
Yeah ofcourse I knew that but how would I go about stopping them being able to surf the object.
pawn Код:
for(new object = 0; object < sizeof(ObjectInfo) object++)
{
if(GetPlayerSurfingObjectID(playerid) == object)
{
??
return 1;
}
}
What options do I have besides teleporting the player?
Re: Stop players surfing specific objects? -
AlonzoTorres - 22.02.2014
You could use it on OnPlayerUpdate instead and return 0.
Re: Stop players surfing specific objects? -
Konstantinos - 22.02.2014
Re-set the player's position maybe.
By the way, I'm not really sure about the way you did it. All you do is checking if it's equal (so a number from 0 to the size of ObjectInfo) and it doesn't actually check if the objectid is equal with the one the function returned.
Quote:
Originally Posted by AlonzoTorres
You could use it on OnPlayerUpdate instead and return 0.
|
It will only desync the player for the rest and the player will keep surfing.
Re: Stop players surfing specific objects? -
Phil_Cutcliffe - 22.02.2014
Quote:
Originally Posted by Konstantinos
Re-set the player's position maybe.
By the way, I'm not really sure about the way you did it. All you do is checking if it's equal (so a number from 0 to the size of ObjectInfo) and it doesn't actually check if the objectid is equal with the one the function returned.
It will only desync the player for the rest and the player will keep surfing.
|
That's part of my object system and it works for every single command I use so I don't see why it wouldn't work for this. Here's an example of how I am using the above example in another command.
pawn Код:
if(strcmp(cmd, "/edit", true) == 0)
{
for(new i = 0; i < sizeof(HouseInfo); i++)
{
if (PlayerToPoint(200.0, playerid,HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
{
if(GetPlayerVirtualWorld(playerid) == HouseInfo[i][EnterWorld])
{
if(PlayerInfo[playerid][pHouse1] == i || PlayerInfo[playerid][pHouse2] == i)
{
for(new object = 0; object < sizeof(ObjectInfo); object++)
{
if(PlayerToPoint(1.5, playerid, ObjectInfo[object][oX], ObjectInfo[object][oY], ObjectInfo[object][oZ]))
{
DestroyDynamicObject(ObjectInfo[object][oObject]);
ObjectInfo[object][oObject] = CreateObject(ObjectInfo[object][oModel],ObjectInfo[object][oX],ObjectInfo[object][oY],ObjectInfo[object][oZ],ObjectInfo[object][oRX],ObjectInfo[object][oRY],ObjectInfo[object][oRZ]);
EditObject(playerid, ObjectInfo[object][oObject]);
SendClientMessage(playerid, COLOR_ORANGE, "You're now editing the object.");
EditingObject[playerid] = object;
return 1;
}
}
}
}
}
}
}
The code I specified in regards to surfing will do a check on the objects in my object system and if it is equal to an object ID it will do something.
EDIT: Had a brain wave..
pawn Код:
if(response == EDIT_RESPONSE_CANCEL)
Can I call this some how? Is it like a character playerstate or something?
Re: Stop players surfing specific objects? -
Konstantinos - 22.02.2014
Using only the loop will fail. In the code you posted above, you store the objectid into
ObjectInfo[object][oObject].
Also you use destroy a
dynamic object and then you assign to that variable the objectid using CreateObject (which is not dynamic).
Last, I'm not sure if GetPlayerSurfingObjectID will return correct objectid if the object was created with CreateDynamicObject (per-player object). In case it does, this may work:
pawn Код:
new surf_obj = GetPlayerSurfingObjectID(playerid);
for(new object = 0; object < sizeof(ObjectInfo) object++)
{
if(surf_object != INVALID_OBJECT_ID && surf_object == ObjectInfo[object][oObject])
{
// re-set the player's position
break;
}
}
Re: Stop players surfing specific objects? -
Phil_Cutcliffe - 22.02.2014
Quote:
Originally Posted by Konstantinos
Using only the loop will fail. In the code you posted above, you store the objectid into ObjectInfo[object][oObject].
Also you use destroy a dynamic object and then you assign to that variable the objectid using CreateObject (which is not dynamic).
Last, I'm not sure if GetPlayerSurfingObjectID will return correct objectid if the object was created with CreateDynamicObject (per-player object). In case it does, this may work:
pawn Код:
new surf_obj = GetPlayerSurfingObjectID(playerid); for(new object = 0; object < sizeof(ObjectInfo) object++) { if(surf_object != INVALID_OBJECT_ID && surf_object == ObjectInfo[object][oObject]) { // re-set the player's position break; } }
|
The reason I destroy the dynamic object and create an ordinary createobject is because the GUI editor of objects does not work sufficiently with dynamic objects. I've tried and it's not worked. My code works fine any way that's off topic. How can I call what I just asked in the post above I edited. That will work fine if I can call it some how.
Re: Stop players surfing specific objects? -
Phil_Cutcliffe - 24.02.2014
Ok I'm looking for a fix for getting a players surfing object ID when it is dynamic... Here's what I tried...
pawn Код:
public OnPlayerUpdate(playerid)
{
if(EditMode[playerid] == 1)
{
for(new object = 0; object < sizeof(ObjectInfo); object++)
{
if(GetPlayerSurfingObjectID(playerid) == ObjectInfo[object][oObject])
{
CancelEdit(playerid);
GameTextForPlayer(playerid, "~r~OBJECT SURFING DETECTED", 3000, 5);
EditMode[playerid] = 0;
return 1;
}
}
}
return 1;
}