SA-MP Forums Archive
Two questions, pls help T_T - 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: Two questions, pls help T_T (/showthread.php?tid=22168)



Two questions, pls help T_T - MidoBan - 13.01.2008

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 :/


Re: Two questions, pls help T_T - Pghpunkid - 13.01.2008

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.


Re: Two questions, pls help T_T - Cilyotri - 06.05.2009

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


Re: Two questions, pls help T_T - SpiderPork - 06.05.2009

Bump a more than 1 year old topic? Why?


Re: Two questions, pls help T_T - Danut - 06.05.2009

this will don't work

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

that space ... start [space] sail


Re: Two questions, pls help T_T - Pghpunkid - 08.05.2009

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.


Re: Two questions, pls help T_T - Backwardsman97 - 08.05.2009

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