Two questions, pls help T_T
#1

Question 1:
I wrote a script that takes a ship (an object) on a sail from one point to another,
and when the ship reaches the second point it changes its rotation (takes a turn).
The problem is that when the ship reaches point 2 it doesn’t rotate!! just staying put!!

The script is using a while loop to always check if the current position of the ship equals to the destination point.

pls pls tell me what’s wrong with the script, I’m sorry but i just started with scripting (I tried reading some guides). Here is the script:

new ship;
new Float;
new Float:y;
new Float:z;
new n=0;

public OnGameModeInit()
{
ship = CreateObject(8493, 1957.874756, 541.984558, 17.617411, 0.0000, 0.0000, 266.3215);
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/start sail", true)==0)
{
MoveObject(ship,2163.3489,487.2763,17.617411,25);
while (n == 0)
{
GetObjectPos(ship, x, y, z);
if ((x==2163.3489) && (y==487.2763) && (z==17.617411))
{
n = 1;
}
}
SetObjectRot(ship, 0, 30, 0);
return 1;
}
return 0;
}


Question 2:
How can i limit a command (for example - a teleport) so that only admins can use it?

Thank u!!
Its my first post on this forum so i hope it's in it's right place :/
Reply
#2

its the right place.. lol

and for making it admin only, use IsPlayerAdmin(playerid). There are TONS of scripts with examples..
as far as the ship Rotation goes, no idea.. i dont fiddle with objects much.. sorry.
Reply
#3

Hello !
Sorry for my late (and for my anglish => I'm french ^^)

So... It's your code:

new ship;
new Float;
new Float:y;
new Float:z;
new n=0;

public OnGameModeInit()
{
ship = CreateObject(8493, 1957.874756, 541.984558, 17.617411, 0.0000, 0.0000, 266.3215);
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/start sail", true)==0)
{
MoveObject(ship,2163.3489,487.2763,17.617411,25);
while (n == 0)
{
GetObjectPos(ship, x, y, z);
if ((x==2163.3489) && (y==487.2763) && (z==17.617411))
{
n = 1;
}
}
SetObjectRot(ship, 0, 30, 0);
return 1;
}
return 0;
}

and your code by me :

new ship;
new Float;
new Float:y;
new Float:z;
new n=0;

public OnGameModeInit()
{
ship = CreateObject(8493, 1957.874756, 541.984558, 17.617411, 0.0000, 0.0000, 266.3215);
return 1;
}

if (strcmp(cmdtext, "/startsail", true))
{
if(PlayerInfo[playerid][pAdmin] >= 3)
{
MoveObject(ship,2163.3489,487.2763,17.617411,25);
while (n == 0)
{
GetObjectPos(ship, x, y, z);
if ((x==2163.3489) && (y==487.2763) && (z==17.617411))
{
n = 1;
}
}
SetObjectRot(ship, 0, 30, 0);
return 1;
}
return 0;
}

I don't have do the test but it must be correct
Reply
#4

Bump a more than 1 year old topic? Why?
Reply
#5

this will don't work

if (strcmp(cmdtext, "/start sail", true)==0)

that space ... start [space] sail
Reply
#6

Quote:
Originally Posted by MoroJr™
this will don't work

if (strcmp(cmdtext, "/start sail", true)==0)

that space ... start [space] sail
Cant do spaces.
Reply
#7

Why would someone use a while loop for this? You could just use the OnObjectMoved callback.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)