little help thanks,
#1

Is it possible if this:
PHP код:
if(Houses[house][EHouseOwnerSQLID] = GetPVarInt(playerid"CharID")) { 
then spawn player at the house he owns..


PHP код:
SetPlayerPos(playeridHouses[i][EHouseX],Houses[i][EHouseY],Houses[i][EHouseZ]); 
for ref.

PHP код:
YCMD:buyhouse(playeridparams[], help) {
    new 
msg[128];
    if(
help) {
        
SendClientMessage(playeridX11_WHITE"Used for buying a house");
        return 
1;
    }
    new 
num GetNumOwnedHouses(playerid);
    if(
num >= GetPVarInt(playerid"MaxHouses")) {
        
SendClientMessage(playeridX11_TOMATO_2"You cannot own any more houses!");
        return 
1;
    }
    new 
house getStandingHouse(playerid);
    if(
house == -1) {
        
SendClientMessage(playeridX11_TOMATO_2"You must be standing near a house");
        return 
1;
    }
    if(
Houses[house][EHouseOwnerSQLID] != 0) {
        
SendClientMessage(playeridX11_TOMATO_2"This house is already owned by someone");
        return 
1;
    }
    new 
confirmtext[32];
    if(!
sscanf(params,"s[32]",confirmtext)) {
        if(
strcmp(confirmtext,"confirm"true) != 0) {
            
SendClientMessage(playeridX11_TOMATO_2"You must type /buyhouse confirm");
            return 
1;
        }
    } else {
        
format(msgsizeof(msg), "* This house costs $%s, type /buyhouse confirm",getNumberString(Houses[house][EHouseValue]));
        
SendClientMessage(playeridCOLOR_LIGHTGREENmsg);
        return 
1;
    }
    new 
money GetMoneyEx(playerid);
    if(
money Houses[house][EHouseValue]) {
        
format(msgsizeof(msg), "You do not have enough money, you need $%s more to buy this house.",getNumberString(Houses[house][EHouseValue]-money));
        
SendClientMessage(playeridX11_TOMATO_2msg);
        return 
1;
    }
    
GiveMoneyEx(playerid, -Houses[house][EHouseValue]);
    
setHouseOwner(houseplayerid);
    
SendClientMessage(playeridCOLOR_LIGHTGREEN"* Congratulations on your new house!");
    return 
1;

thanks..
Reply
#2

It's better if you store the house owner in the houses enum, and then check if the player's name and house owner matches.
Reply
#3

Well, in my server I have a variable that is saved in the database which stands for "SpawnAt", it has a few possible values: 0 - Spawn at log-out location, 1 - Spawn at faction HQ, 2+ spawn at the house id, how it works is, when houses are created id 0 and 1 are unused(to be honest, you can make 2 different variables, one for purely storing where he wants to spawn and one for which house id he wants to spawn at, but I was lazy and simply not using slot 0 and 1 looked a lot easier(they are 1$ houses that are floating below the ground somewhere in Las Venturas, forgot even where) so when he does /setspawn he gets a dialog with options to spawn at log-out location(this is forced if a player's disconnect reason was 0 a.k.a crash/timeout tho
) , faction HQ and house, if he clicks house he has to enter his house adress (something like 01 Grove Street) then the script loops through all houses and if he finds that house(obviously, an error pops up if the house is not found or he doesn't own it)then the script sets the "SpawnAt" value to the house SQL id(do not confuse it with the in-game ID, just saying) and then when he spawns with a character switch(CharInfo[someid][SpawnAt]) { case 0: { last pos code; } case 1: { faction hq spawn code; } default: (meaning it's not 0 or 1, in other words there is no case: set for it) { loop through all the houses and see which house has the SpawnAt equal to the sql id, set his position the way you showed; }

This is how I'd do it, of course there's numerous ways of scripting it, if you need more information or you've to ask something that you don't understand, feel free to ask.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)