Cara Load Data Last Lokasi Kendaraan SAMP Dengan MySQL plugin R41-4 Pawn Scripting IsValidVehicle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <a_samp> | |
#include <a_mysql> // MySQL plugin R41-4 | |
new mobilplayer1[MAX_PLAYERS]; | |
public OnPlayerConnect(playerid) | |
{ | |
//SetCameraBehindPlayer(playerid); | |
TogglePlayerControllable(playerid, 1); | |
//SetPlayerSkin(playerid, 187); | |
//0 // supaya ga ada skin selection... | |
// lokasi saat spawn | |
//ConnectMySQL(); | |
GetPlayerName(playerid, pInfo[playerid][Nick], 24); | |
//gets the player's name and stores it to to your enum pInfo[playerid][Nick] | |
GetPlayerIp(playerid, pInfo[playerid][IP], 16); //Gets the IP of the player and stores it to pInfo[playerid][IP] | |
//mysql_connect_file("mysql.ini");// now we have to escape the name inorder to escape any mysql injections. ([url]http://en.wikipedia.org/wiki/SQL_injection[/url]) | |
//format(Query, 500, "SELECT `nick` FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = '%s' LIMIT 1", pInfo[playerid][Nick]); // here we are selecting the name of the player who logged in from the database. | |
//mysql_query(g_Sql, Query, true); | |
new passworddariuser[500]; | |
format(passworddariuser, 500, "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = '%s' LIMIT 1", pInfo[playerid][Nick]); // now here check the database if the player has given the proper password.HTTP | |
//mysql_query(MySQL:handle, const query[], bool:use_cache = true) | |
mysql_query(MySQL:g_Sql, passworddariuser, bool:true); | |
cache_get_value_int(0, "id", pInfo[playerid][ID]); | |
cache_get_value_name(0, "password", pInfo[playerid][Sandi], 50); | |
cache_get_value_name_float(0, "ppx", Float:pInfo[playerid][pPx]); | |
cache_get_value_name_float(0, "ppy", Float:pInfo[playerid][pPy]); | |
cache_get_value_name_float(0, "ppz", Float:pInfo[playerid][pPz]); | |
cache_get_value_name_float(0, "pmx", Float:pInfo[playerid][pMx]); | |
cache_get_value_name_float(0, "pmy", Float:pInfo[playerid][pMy]); | |
cache_get_value_name_float(0, "pmz", Float:pInfo[playerid][pMz]); | |
cache_get_value_name_float(0, "healthm1", Float:pInfo[playerid][pHealtM1]); | |
cache_get_value_int(0, "tipemobil", pInfo[playerid][pTipeMobil]); | |
return 1; | |
} | |
public OnPlayerSpawn(playerid) | |
{ | |
if(!IsValidVehicle(mobilplayer1[playerid])) | |
{ | |
mobilplayer1[playerid] = AddStaticVehicle( pInfo[playerid][pTipeMobil], Float:pInfo[playerid][pMx], Float:pInfo[playerid][pMy], Float:pInfo[playerid][pMz], Float:0.0, -1, -1); | |
SetVehicleVirtualWorld(mobilplayer1[playerid], 0); | |
LinkVehicleToInterior(mobilplayer1[playerid], 0); | |
SetVehicleHealth(mobilplayer1[playerid], Float:pInfo[playerid][pHealtM1]); | |
} | |
else | |
{ | |
SendClientMessage(playerid, -1, "Mobil player slot satu sudah memang ada terspawn."); | |
} | |
if(IsPlayerInRangeOfPoint(playerid, Float:6, Float:pInfo[playerid][pMx], Float:pInfo[playerid][pMy], Float:pInfo[playerid][pMz])) | |
{ | |
// langsung masuk mobil di spawn | |
//AddStaticVehicle(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:z_angle, color1, color2) | |
PutPlayerInVehicle(playerid, mobilplayer1[playerid], 0); | |
} | |
} |
Comments
Post a Comment