Posts: 512
Threads: 121
Joined: Sep 2013
I was thinking to make /spawn command with save and auto-load after onplayerdeath or onplayerspawn then onplayerdisconnect. Note: Im using Y_INI saving include.
So it will be like. If I use /spawn - it will sendclientmessage "Your current spawn point has been save". So when I do suicide after I spawn it should load my current saved spawn point furthermore after I exit the server then came back after I spawn it should still load my current spawn point that I've saved.
Posts: 203
Threads: 14
Joined: Jul 2012
Hmm idk about that. but you can do /save, and the cordinates (place) will be saved into your savedpositions.txt
which you can it add it manually.
Posts: 512
Threads: 121
Joined: Sep 2013
Quote:
Originally Posted by Konstantinos
pawn Код:
new bool: Saved_Pos[ MAX_PLAYERS char ], Float: Saved_X[ MAX_PLAYERS ], Float: Saved_Y[ MAX_PLAYERS ], Float: Saved_Z[ MAX_PLAYERS ], Float: saved_Angle[ MAX_PLAYERS ] ;
public OnPlayerSpawn( playerid ) { if( Saved_Pos{ playerid } ) { SetPlayerPos( playerid, Saved_X[ playerid ], Saved_Y[ playerid ], Saved_Z[ playerid ] ); SetPlayerFacingAngle( playerid, Saved_Angle[ playerid ] ); } else { // set the position for those who has not saved } return 1; }
// Command /spawn GetPlayerPos( playerid, Saved_X[ playerid ], Saved_Y[ playerid ], Saved_Z[ playerid ] ); GetPlayerFacingAngle( playerid, Saved_Angle[ playerid ] ); Saved_Pos{ playerid } = true;
// NOTE1: When they disconnect, save the position (X, Y, Z, Angle) to the file as well as whether they've a saved position // NOTE2: When they loggin, assign the floats to the variables above and also to the Saved_Pos // NOTE3: Do not forget to reset the variables on connect
|
Warnings..
Код:
error 017: undefined symbol "Saved_Angle"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
Line
Код:
SetPlayerFacingAngle( playerid, Saved_Angle[ playerid ] );
Do I need to make INI_WriteInt or INI_Int? If I had to how? Thanks
EDIT: ive added this on top
Код:
new
bool: Saved_Pos[ MAX_PLAYERS char ],
Float: Saved_X[ MAX_PLAYERS ],
Float: Saved_Y[ MAX_PLAYERS ],
Float: Saved_Z[ MAX_PLAYERS ],
Float: saved_Angle[ MAX_PLAYERS ];
Posts: 11,827
Threads: 33
Joined: Dec 2011
Reputation:
0
You have written saved_Angle when it should be Saved_Angle.
INI_WriteInt - write to a file
INI_Int - to read from a file
Posts: 512
Threads: 121
Joined: Sep 2013
Quote:
Originally Posted by Konstantinos
You have written saved_Angle when it should be Saved_Angle.
INI_WriteInt - write to a file
INI_Int - to read from a file
|
Thanks man its good now. But what should I put in INI_WriteInt and INIT_Int??
Sample..
INI_WriteInt(ACCOUNT, "Kills", 0);
INI_Int("Kills", pInfo[playerid][Kills]);
How about position?
Edit: Like this?
INI_WriteInt(ACCOUNT, "Saved_X", 0); ??
Posts: 512
Threads: 121
Joined: Sep 2013
Quote:
Originally Posted by Konstantinos
There are many tutorials about how to use y_ini. Read some of them!
By the way, the coordinates are floats thus it should be:
INI_WriteFloat
INI_Float
The above was for integers and actually are not useful to your case. The boolean can be used with INI_Bool/INI_WriteBool.
For more information, go: https://sampforum.blast.hk/showthread.php?tid=175565
|
Thanks for the reply. I use this and exactly what I wanted:
https://sampforum.blast.hk/showthread.php?tid=299791
but the problem I tried to make my own /spawn command
Код:
CMD:spawn(playerid,params[])
{
GetPlayerPos( playerid, PosX[ playerid ], PosY[ playerid ], PosZ[ playerid ] );
GetPlayerFacingAngle( playerid, Angle[ playerid ] );
GetPlayerInterior( playerid, Interior[ playerid ] );
GetPlayerVirtualWorld( playerid, VirtualWorld[ playerid ] );
SendClientMessage( playerid, -1, "welcome to your last position" );
return 1;
}
And I got warningg warning 202: number of arguments does not match definition. From this line
Код:
GetPlayerInterior( playerid, Interior[ playerid ] );
GetPlayerVirtualWorld( playerid, VirtualWorld[ playerid ] );
EDIT: I didn't put this in my filterscript because it already has and load system. is that okay?